Skip to content

Commit ee32c22

Browse files
Craig Berrycraigberry
authored andcommitted
In HttpGetFile, delete file after failure
But only if it was successfully opened.
1 parent e20aef8 commit ee32c22

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Win32.xs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,12 @@ XS(w32_HttpGetFile)
19281928
if (bAborted)
19291929
error = GetLastError();
19301930

1931+
/* If we successfully opened the output file but failed later, mark
1932+
* the file for deletion.
1933+
*/
1934+
if (bAborted && hOut != INVALID_HANDLE_VALUE)
1935+
(void) DeleteFileW(file);
1936+
19311937
/* Close any open handles. */
19321938
if (hOut) CloseHandle(hOut);
19331939
if (hRequest) WinHttpCloseHandle(hRequest);

0 commit comments

Comments
 (0)