Forráskód Böngészése

lib/model: Leave temp file in place when final rename fails (fixes #3146)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3148
Jakob Borg 9 éve
szülő
commit
44290a66b7
1 módosított fájl, 3 hozzáadás és 2 törlés
  1. 3 2
      lib/model/rwfolder.go

+ 3 - 2
lib/model/rwfolder.go

@@ -1297,8 +1297,9 @@ func (f *rwFolder) performFinish(state *sharedPullerState) error {
 		}
 	}
 
-	// Replace the original content with the new one
-	if err := osutil.Rename(state.tempName, state.realName); err != nil {
+	// Replace the original content with the new one. If it didn't work,
+	// leave the temp file in place for reuse.
+	if err := osutil.TryRename(state.tempName, state.realName); err != nil {
 		return err
 	}