diff --git a/stbridge/stbridge.go b/stbridge/stbridge.go index 9af6264..b2b14bc 100644 --- a/stbridge/stbridge.go +++ b/stbridge/stbridge.go @@ -447,6 +447,10 @@ func Run(startup *SyncthingStartupConfig) error { return nil } +func isDatabase(relPath string) bool { + return strings.HasPrefix(filepath.Clean(relPath), "index-") +} + func ZipErrorWrongPassword() string { return zip.ErrPassword.Error() } @@ -501,6 +505,15 @@ func ImportConfiguration(fd int, name string, password string) error { return nil } + // We intentionally skip the database to ensure that Syncthing pulls + // down missing files instead of assuming that they were deleted. The + // service could take much longer to rescan the folders if all of the + // data is already present, but this is much safer. + if isDatabase(f.Name) { + log.Printf("Skipping: %q", f.Name) + return nil + } + // Join() normalizes the path too. path := filepath.Join(tempDir, f.Name) if !strings.HasPrefix(path, tempDir+string(os.PathSeparator)) { @@ -572,6 +585,11 @@ func ExportConfiguration(fd int, name string, password string) error { return fmt.Errorf("failed to compute relative path: %q: %w", path, err) } + if isDatabase(relPath) { + log.Printf("Skipping: %q", relPath) + return nil + } + input, err := os.Open(path) if err != nil { return fmt.Errorf("failed to open for reading: %q: %w", path, err)