Commit 75dda08f authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

config: Remove temporary file if replacement failed

parent 644185a5
...@@ -680,7 +680,8 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name, ...@@ -680,7 +680,8 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
#ifndef WIN32 #ifndef WIN32
fdatasync (fd); /* Flush from OS */ fdatasync (fd); /* Flush from OS */
/* Atomically replace the file... */ /* Atomically replace the file... */
utf8_rename (temporary, permanent); if (utf8_rename (temporary, permanent))
utf8_unlink (temporary);
/* (...then synchronize the directory, err, TODO...) */ /* (...then synchronize the directory, err, TODO...) */
/* ...and finally close the file */ /* ...and finally close the file */
vlc_mutex_unlock (&lock); vlc_mutex_unlock (&lock);
...@@ -689,7 +690,8 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name, ...@@ -689,7 +690,8 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
#ifdef WIN32 #ifdef WIN32
/* Windows cannot remove open files nor overwrite existing ones */ /* Windows cannot remove open files nor overwrite existing ones */
utf8_unlink (permanent); utf8_unlink (permanent);
utf8_rename (temporary, permanent); if (utf8_rename (temporary, permanent))
utf8_unlink (temporary);
vlc_mutex_unlock (&lock); vlc_mutex_unlock (&lock);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment