]> khamidou — GitHub mirrors - electron.git/commitdiff
win: Delete temp file on reboot, fix #1084
authorCheng Zhao <zcbenz@gmail.com>
Tue, 3 Feb 2015 01:03:52 +0000 (17:03 -0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 3 Feb 2015 01:03:52 +0000 (17:03 -0800)
atom/common/asar/scoped_temporary_file.cc

index d7e4dabb9db7f0b5a5a9cb69291af139ab8a7b11..574f178f6f3438b240c1147bde5ab7305353b170 100644 (file)
@@ -16,12 +16,13 @@ ScopedTemporaryFile::ScopedTemporaryFile() {
 
 ScopedTemporaryFile::~ScopedTemporaryFile() {
   if (!path_.empty()) {
-    // On Windows calling base::DeleteFile on exit will call an API that would
-    // halt the program, so we have to call the win32 API directly.
+    base::ThreadRestrictions::ScopedAllowIO allow_io;
+    // On Windows it is very likely the file is already in use (because it is
+    // mostly used for Node native modules), so deleting it now will halt the
+    // program.
 #if defined(OS_WIN)
-    ::DeleteFile(path_.value().c_str());
+    base::DeleteFileAfterReboot(path_);
 #else
-    base::ThreadRestrictions::ScopedAllowIO allow_io;
     base::DeleteFile(path_, false);
 #endif
   }