Browse Source

Fix: invalid partial download failed to reset on Windows
- when ETag file is missing, partial download should be
deleted, to reset the download state
- on Windows, the delete fails as the partial download file
is still open; subsequent retries continue to fail
- going forward, emit Notice with related os.Remove failures

Rod Hynes 9 years ago
parent
commit
a8cac1576d
1 changed files with 14 additions and 2 deletions
  1. 14 2
      psiphon/net.go

+ 14 - 2
psiphon/net.go

@@ -440,8 +440,20 @@ func ResumeDownload(
 		// that the controller's upgradeDownloader will shortly call DownloadUpgrade
 		// again.
 		if err != nil {
-			os.Remove(partialFilename)
-			os.Remove(partialETagFilename)
+
+			// On Windows, file must be closed before it can be deleted
+			file.Close()
+
+			tempErr := os.Remove(partialFilename)
+			if tempErr != nil && !os.IsNotExist(tempErr) {
+				NoticeAlert("reset partial download failed: %s", tempErr)
+			}
+
+			tempErr = os.Remove(partialETagFilename)
+			if tempErr != nil && !os.IsNotExist(tempErr) {
+				NoticeAlert("reset partial download ETag failed: %s", tempErr)
+			}
+
 			return 0, "", common.ContextError(
 				fmt.Errorf("failed to load partial download ETag: %s", err))
 		}