Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions stbridge/stbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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)
Expand Down