From: RĂ©mi Denis-Courmont Date: Sun, 12 Jul 2009 17:54:08 +0000 (+0300) Subject: config: Remove temporary file if replacement failed X-Git-Tag: 1.1.0-ff~5008 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=75dda08f9fd7b2e80b9587dbf329bc262b3c8ba9;p=vlc config: Remove temporary file if replacement failed --- diff --git a/src/config/file.c b/src/config/file.c index 9b779ab1b4..10a483e1f0 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