lib/db, lib/model: Remove folder info from panics (ref #5839) (#5840)

This commit is contained in:
Simon Frei 2019-07-10 10:57:49 +02:00 committed by Jakob Borg
parent 85318f3b82
commit 9fef1552fc
2 changed files with 12 additions and 6 deletions

View File

@ -172,7 +172,8 @@ func (db *instance) withHaveSequence(folder []byte, startSeq int64, fn Iterator)
if shouldDebug() {
if seq := db.keyer.SequenceFromSequenceKey(dbi.Key()); f.Sequence != seq {
panic(fmt.Sprintf("sequence index corruption (folder %v, file %v): sequence %d != expected %d", string(folder), f.Name, f.Sequence, seq))
l.Warnf("Sequence index corruption (folder %v, file %v): sequence %d != expected %d", string(folder), f.Name, f.Sequence, seq)
panic("sequence index corruption")
}
}
if !fn(f) {

View File

@ -257,9 +257,11 @@ func (m *model) StartFolder(folder string) {
// Need to hold lock on m.fmut when calling this.
func (m *model) startFolderLocked(cfg config.FolderConfiguration) {
if err := m.checkFolderRunningLocked(cfg.ID); err == errFolderMissing {
panic("cannot start nonexistent folder " + cfg.Description())
l.Warnln("Cannot start nonexistent folder", cfg.Description())
panic("cannot start nonexistent folder")
} else if err == nil {
panic("cannot start already running folder " + cfg.Description())
l.Warnln("Cannot start already running folder", cfg.Description())
panic("cannot start already running folder")
}
folderFactory, ok := folderFactories[cfg.Type]
@ -435,7 +437,8 @@ func (m *model) RestartFolder(from, to config.FolderConfiguration) {
panic("bug: cannot restart empty folder ID")
}
if to.ID != from.ID {
panic(fmt.Sprintf("bug: folder restart cannot change ID %q -> %q", from.ID, to.ID))
l.Warnf("bug: folder restart cannot change ID %q -> %q", from.ID, to.ID)
panic("bug: folder restart cannot change ID")
}
// This mutex protects the entirety of the restart operation, preventing
@ -995,7 +998,8 @@ func (m *model) handleIndex(deviceID protocol.DeviceID, folder string, fs []prot
m.fmut.RUnlock()
if !existing {
panic(fmt.Sprintf("%v for nonexistent folder %q", op, folder))
l.Warnf("%v for nonexistent folder %q", op, folder)
panic("handling index for nonexistent folder")
}
if running {
@ -1003,7 +1007,8 @@ func (m *model) handleIndex(deviceID protocol.DeviceID, folder string, fs []prot
} else if update {
// Runner may legitimately not be set if this is the "cleanup" Index
// message at startup.
panic(fmt.Sprintf("%v for not running folder %q", op, folder))
l.Warnf("%v for not running folder %q", op, folder)
panic("handling index for not running folder")
}
m.pmut.RLock()