[vlc-devel] commit: config: Remove temporary file if replacement failed ( Rémi Denis-Courmont )

git version control git at videolan.org
Sun Jul 12 19:55:05 CEST 2009


vlc | branch: 1.0-bugfix | Rémi Denis-Courmont <remi at remlab.net> | Sun Jul 12 20:54:08 2009 +0300| [c12aa0640d0812b537f92586e2280ca9b12d6d75] | committer: Rémi Denis-Courmont 

config: Remove temporary file if replacement failed
(cherry picked from commit 75dda08f9fd7b2e80b9587dbf329bc262b3c8ba9)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c12aa0640d0812b537f92586e2280ca9b12d6d75
---

 src/config/file.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/config/file.c b/src/config/file.c
index 6c411f2..3b7ed94 100644
--- a/src/config/file.c
+++ b/src/config/file.c
@@ -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
 




More information about the vlc-devel mailing list