mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +00:00
lib/model: Log folder IDs and labels (fixes #3724)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3741
This commit is contained in:
parent
be80b26c18
commit
d3a251e6d9
@ -7,6 +7,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -103,6 +104,10 @@ func (f *FolderConfiguration) HasMarker() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FolderConfiguration) Description() string {
|
||||||
|
return fmt.Sprintf("%q (%s)", f.Label, f.ID)
|
||||||
|
}
|
||||||
|
|
||||||
func (f *FolderConfiguration) DeviceIDs() []protocol.DeviceID {
|
func (f *FolderConfiguration) DeviceIDs() []protocol.DeviceID {
|
||||||
deviceIDs := make([]protocol.DeviceID, len(f.Devices))
|
deviceIDs := make([]protocol.DeviceID, len(f.Devices))
|
||||||
for i, n := range f.Devices {
|
for i, n := range f.Devices {
|
||||||
|
@ -189,12 +189,12 @@ func (m *Model) StartFolder(folder string) {
|
|||||||
func (m *Model) startFolderLocked(folder string) config.FolderType {
|
func (m *Model) startFolderLocked(folder string) config.FolderType {
|
||||||
cfg, ok := m.folderCfgs[folder]
|
cfg, ok := m.folderCfgs[folder]
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("cannot start nonexistent folder " + folder)
|
panic("cannot start nonexistent folder " + cfg.Description())
|
||||||
}
|
}
|
||||||
|
|
||||||
_, ok = m.folderRunners[folder]
|
_, ok = m.folderRunners[folder]
|
||||||
if ok {
|
if ok {
|
||||||
panic("cannot start already running folder " + folder)
|
panic("cannot start already running folder " + cfg.Description())
|
||||||
}
|
}
|
||||||
|
|
||||||
folderFactory, ok := folderFactories[cfg.Type]
|
folderFactory, ok := folderFactories[cfg.Type]
|
||||||
@ -806,19 +806,19 @@ func (m *Model) ClusterConfig(deviceID protocol.DeviceID, cm protocol.ClusterCon
|
|||||||
// the IndexID, or something else weird has
|
// the IndexID, or something else weird has
|
||||||
// happened. We send a full index to reset the
|
// happened. We send a full index to reset the
|
||||||
// situation.
|
// situation.
|
||||||
l.Infof("Device %v folder %q is delta index compatible, but seems out of sync with reality", deviceID, folder.ID)
|
l.Infof("Device %v folder %q (%s) is delta index compatible, but seems out of sync with reality", deviceID, folder.Label, folder.ID)
|
||||||
startSequence = 0
|
startSequence = 0
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
l.Debugf("Device %v folder %q is delta index compatible (mlv=%d)", deviceID, folder.ID, dev.MaxSequence)
|
l.Debugf("Device %v folder %q (%s) is delta index compatible (mlv=%d)", deviceID, folder.Label, folder.ID, dev.MaxSequence)
|
||||||
startSequence = dev.MaxSequence
|
startSequence = dev.MaxSequence
|
||||||
} else if dev.IndexID != 0 {
|
} else if dev.IndexID != 0 {
|
||||||
// They say they've seen an index ID from us, but it's
|
// They say they've seen an index ID from us, but it's
|
||||||
// not the right one. Either they are confused or we
|
// not the right one. Either they are confused or we
|
||||||
// must have reset our database since last talking to
|
// must have reset our database since last talking to
|
||||||
// them. We'll start with a full index transfer.
|
// them. We'll start with a full index transfer.
|
||||||
l.Infof("Device %v folder %q has mismatching index ID for us (%v != %v)", deviceID, folder.ID, dev.IndexID, myIndexID)
|
l.Infof("Device %v folder %q (%s) has mismatching index ID for us (%v != %v)", deviceID, folder.Label, folder.ID, dev.IndexID, myIndexID)
|
||||||
startSequence = 0
|
startSequence = 0
|
||||||
}
|
}
|
||||||
} else if dev.ID == deviceID && dev.IndexID != 0 {
|
} else if dev.ID == deviceID && dev.IndexID != 0 {
|
||||||
@ -840,7 +840,7 @@ func (m *Model) ClusterConfig(deviceID protocol.DeviceID, cm protocol.ClusterCon
|
|||||||
// will probably send us a full index. We drop any
|
// will probably send us a full index. We drop any
|
||||||
// information we have and remember this new index ID
|
// information we have and remember this new index ID
|
||||||
// instead.
|
// instead.
|
||||||
l.Infof("Device %v folder %q has a new index ID (%v)", deviceID, folder.ID, dev.IndexID)
|
l.Infof("Device %v folder %q (%s) has a new index ID (%v)", deviceID, folder.Label, folder.ID, dev.IndexID)
|
||||||
fs.Replace(deviceID, nil)
|
fs.Replace(deviceID, nil)
|
||||||
fs.SetIndexID(deviceID, dev.IndexID)
|
fs.SetIndexID(deviceID, dev.IndexID)
|
||||||
} else {
|
} else {
|
||||||
@ -952,7 +952,7 @@ func (m *Model) handleDeintroductions(introducerCfg config.DeviceConfiguration,
|
|||||||
// We could not find that folder shared on the
|
// We could not find that folder shared on the
|
||||||
// introducer with the device that was introduced to us.
|
// introducer with the device that was introduced to us.
|
||||||
// We should follow and unshare aswell.
|
// We should follow and unshare aswell.
|
||||||
l.Infof("Unsharing folder %q with %v as introducer %v no longer shares the folder with that device", folderCfg.ID, folderCfg.Devices[i].DeviceID, folderCfg.Devices[i].IntroducedBy)
|
l.Infof("Unsharing folder %s with %v as introducer %v no longer shares the folder with that device", folderCfg.Description(), folderCfg.Devices[i].DeviceID, folderCfg.Devices[i].IntroducedBy)
|
||||||
folderCfg.Devices = append(folderCfg.Devices[:i], folderCfg.Devices[i+1:]...)
|
folderCfg.Devices = append(folderCfg.Devices[:i], folderCfg.Devices[i+1:]...)
|
||||||
i--
|
i--
|
||||||
folderChanged = true
|
folderChanged = true
|
||||||
@ -1020,7 +1020,7 @@ func (m *Model) introduceDevice(device protocol.Device, introducerCfg config.Dev
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) introduceDeviceToFolder(device protocol.Device, folder protocol.Folder, introducerCfg config.DeviceConfiguration) {
|
func (m *Model) introduceDeviceToFolder(device protocol.Device, folder protocol.Folder, introducerCfg config.DeviceConfiguration) {
|
||||||
l.Infof("Sharing folder %q with %v (vouched for by introducer %v)", folder.ID, device.ID, introducerCfg.DeviceID)
|
l.Infof("Sharing folder %q (%s) with %v (vouched for by introducer %v)", folder.Label, folder.ID, device.ID, introducerCfg.DeviceID)
|
||||||
|
|
||||||
m.deviceFolders[device.ID] = append(m.deviceFolders[device.ID], folder.ID)
|
m.deviceFolders[device.ID] = append(m.deviceFolders[device.ID], folder.ID)
|
||||||
m.folderDevices.set(device.ID, folder.ID)
|
m.folderDevices.set(device.ID, folder.ID)
|
||||||
@ -1735,14 +1735,14 @@ func (m *Model) internalScanFolderSubdirs(folder string, subDirs []string) error
|
|||||||
|
|
||||||
if err := m.CheckFolderHealth(folder); err != nil {
|
if err := m.CheckFolderHealth(folder); err != nil {
|
||||||
runner.setError(err)
|
runner.setError(err)
|
||||||
l.Infof("Stopping folder %s due to error: %s", folder, err)
|
l.Infof("Stopping folder %s due to error: %s", folderCfg.Description(), err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ignores.Load(filepath.Join(folderCfg.Path(), ".stignore")); err != nil && !os.IsNotExist(err) {
|
if err := ignores.Load(filepath.Join(folderCfg.Path(), ".stignore")); err != nil && !os.IsNotExist(err) {
|
||||||
err = fmt.Errorf("loading ignores: %v", err)
|
err = fmt.Errorf("loading ignores: %v", err)
|
||||||
runner.setError(err)
|
runner.setError(err)
|
||||||
l.Infof("Stopping folder %s due to error: %s", folder, err)
|
l.Infof("Stopping folder %s due to error: %s", folderCfg.Description(), err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1799,7 +1799,7 @@ func (m *Model) internalScanFolderSubdirs(folder string, subDirs []string) error
|
|||||||
for f := range fchan {
|
for f := range fchan {
|
||||||
if len(batch) == batchSizeFiles || blocksHandled > batchSizeBlocks {
|
if len(batch) == batchSizeFiles || blocksHandled > batchSizeBlocks {
|
||||||
if err := m.CheckFolderHealth(folder); err != nil {
|
if err := m.CheckFolderHealth(folder); err != nil {
|
||||||
l.Infof("Stopping folder %s mid-scan due to folder error: %s", folder, err)
|
l.Infof("Stopping folder %s mid-scan due to folder error: %s", folderCfg.Description(), err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
m.updateLocalsFromScanning(folder, batch)
|
m.updateLocalsFromScanning(folder, batch)
|
||||||
@ -1811,7 +1811,7 @@ func (m *Model) internalScanFolderSubdirs(folder string, subDirs []string) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := m.CheckFolderHealth(folder); err != nil {
|
if err := m.CheckFolderHealth(folder); err != nil {
|
||||||
l.Infof("Stopping folder %s mid-scan due to folder error: %s", folder, err)
|
l.Infof("Stopping folder %s mid-scan due to folder error: %s", folderCfg.Description(), err)
|
||||||
return err
|
return err
|
||||||
} else if len(batch) > 0 {
|
} else if len(batch) > 0 {
|
||||||
m.updateLocalsFromScanning(folder, batch)
|
m.updateLocalsFromScanning(folder, batch)
|
||||||
@ -1887,13 +1887,13 @@ func (m *Model) internalScanFolderSubdirs(folder string, subDirs []string) error
|
|||||||
})
|
})
|
||||||
|
|
||||||
if iterError != nil {
|
if iterError != nil {
|
||||||
l.Infof("Stopping folder %s mid-scan due to folder error: %s", folder, iterError)
|
l.Infof("Stopping folder %s mid-scan due to folder error: %s", folderCfg.Description(), iterError)
|
||||||
return iterError
|
return iterError
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := m.CheckFolderHealth(folder); err != nil {
|
if err := m.CheckFolderHealth(folder); err != nil {
|
||||||
l.Infof("Stopping folder %s mid-scan due to folder error: %s", folder, err)
|
l.Infof("Stopping folder %s mid-scan due to folder error: %s", folderCfg.Description(), err)
|
||||||
return err
|
return err
|
||||||
} else if len(batch) > 0 {
|
} else if len(batch) > 0 {
|
||||||
m.updateLocalsFromScanning(folder, batch)
|
m.updateLocalsFromScanning(folder, batch)
|
||||||
@ -2291,9 +2291,9 @@ func (m *Model) runnerExchangeError(folder config.FolderConfiguration, err error
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if oldErr != nil && oldErr.Error() != err.Error() {
|
if oldErr != nil && oldErr.Error() != err.Error() {
|
||||||
l.Infof("Folder %q error changed: %q -> %q", folder.ID, oldErr, err)
|
l.Infof("Folder %s error changed: %q -> %q", folder.Description(), oldErr, err)
|
||||||
} else if oldErr == nil {
|
} else if oldErr == nil {
|
||||||
l.Warnf("Stopping folder %q - %v", folder.ID, err)
|
l.Warnf("Stopping folder %s - %v", folder.Description(), err)
|
||||||
}
|
}
|
||||||
if runnerExists {
|
if runnerExists {
|
||||||
runner.setError(err)
|
runner.setError(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user