From 44290a66b7904527ca6466e9ab003301caf65a2c Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sun, 22 May 2016 09:06:07 +0000 Subject: [PATCH] lib/model: Leave temp file in place when final rename fails (fixes #3146) GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3148 --- lib/model/rwfolder.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/model/rwfolder.go b/lib/model/rwfolder.go index 40e00f56..01d4d38c 100644 --- a/lib/model/rwfolder.go +++ b/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 }