فهرست منبع

lib/model: Hide temporary files on Windows while they are in use (fixes #4382)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4394
Jakob Borg 8 سال پیش
والد
کامیت
a365ae51c4
1فایلهای تغییر یافته به همراه9 افزوده شده و 0 حذف شده
  1. 9 0
      lib/model/sharedpullerstate.go

+ 9 - 0
lib/model/sharedpullerstate.go

@@ -164,6 +164,9 @@ func (s *sharedPullerState) tempFile() (io.WriterAt, error) {
 		return nil, err
 		return nil, err
 	}
 	}
 
 
+	// Hide the temporary file
+	s.fs.Hide(s.tempName)
+
 	// Don't truncate symlink files, as that will mean that the path will
 	// Don't truncate symlink files, as that will mean that the path will
 	// contain a bunch of nulls.
 	// contain a bunch of nulls.
 	if s.sparse && !s.file.IsSymlink() {
 	if s.sparse && !s.file.IsSymlink() {
@@ -307,6 +310,12 @@ func (s *sharedPullerState) finalClose() (bool, error) {
 
 
 	s.closed = true
 	s.closed = true
 
 
+	// Unhide the temporary file when we close it, as it's likely to
+	// immediately be renamed to the final name. If this is a failed temp
+	// file we will also unhide it, but I'm fine with that as we're now
+	// leaving it around for potentially quite a while.
+	s.fs.Unhide(s.tempName)
+
 	return true, s.err
 	return true, s.err
 }
 }