]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Using the temporary file flags didn't work.
authorDaira Hopwood <daira@jacaranda.org>
Tue, 28 Oct 2014 16:52:49 +0000 (16:52 +0000)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 28 Oct 2014 16:52:49 +0000 (16:52 +0000)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
misc/build_helpers/windows/installer/installer/installer.cpp

index 7cb5357329f458e816fd9f94882deb0f9c2033e3..e8483f0462900ff04ec5ad4fa383f3f56521d6e8 100644 (file)
@@ -125,18 +125,12 @@ void unzip_from_executable(wchar_t *executable_path, wchar_t *destination_dir) {
        fail_unless(len < MAX_PATH - wcslen(tmp_filename), "Temporary directory path is too long.");
        wcscpy(tmp_path + len, tmp_filename);
 
-       // "TD" => short-lived temporary file. The D flag ensures that the file is guaranteed
-       // to be deleted even if we exit suddenly. In order to reliably flush writes but also
-       // ensure that the temporary file isn't deleted too soon, we duplicate the file handle
-       // while the file is being unzipped.
        errno = 0;
-       FILE *tmp_file = _wfopen(tmp_path, L"wbTD");
+       FILE *tmp_file = _wfopen(tmp_path, L"wb");
        fail_unless(tmp_file != NULL && errno == 0 && ferror(f) == 0,
                        "Could not open temporary zip file.");
 
-       int tmp_file_keepopen = _dup(_fileno(tmp_file));
-       fail_unless(errno == 0, "Could not duplicate file descriptor for temporary zip file.");
-
+       // FIXME: delete the temporary file if there is an error.
        unsigned char buf[16384];
        size_t remaining_length = (size_t) zip_length;
        while (remaining_length > 0) {
@@ -154,7 +148,7 @@ void unzip_from_executable(wchar_t *executable_path, wchar_t *destination_dir) {
        fclose(f); // ignore errors
 
        unzip(tmp_path, destination_dir);
-       _close(tmp_file_keepopen); // ignore errors
+       _wunlink(tmp_path); // ignore errors
 }
 
 // read unsigned little-endian 32-bit integer