]> git.sesse.net Git - vlc/commitdiff
config: Remove temporary file if replacement failed
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 12 Jul 2009 17:54:08 +0000 (20:54 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 12 Jul 2009 17:54:08 +0000 (20:54 +0300)
src/config/file.c

index 9b779ab1b420ed9372435da63dcd57bac6d75d10..10a483e1f08a36df72e5a2c1990215f9e0f164a6 100644 (file)
@@ -680,7 +680,8 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
 #ifndef WIN32
     fdatasync (fd); /* Flush from OS */
     /* Atomically replace the file... */
-    utf8_rename (temporary, permanent);
+    if (utf8_rename (temporary, permanent))
+        utf8_unlink (temporary);
     /* (...then synchronize the directory, err, TODO...) */
     /* ...and finally close the file */
     vlc_mutex_unlock (&lock);
@@ -689,7 +690,8 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
 #ifdef WIN32
     /* Windows cannot remove open files nor overwrite existing ones */
     utf8_unlink (permanent);
-    utf8_rename (temporary, permanent);
+    if (utf8_rename (temporary, permanent))
+        utf8_unlink (temporary);
     vlc_mutex_unlock (&lock);
 #endif