[vlc-commits] addons: Don't keep an incomplete file on error

Hugo Beauzée-Luyssen git at videolan.org
Fri Nov 3 17:03:27 CET 2017


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Nov  2 11:22:41 2017 +0100| [956a77a8acc4d86494176746d0e01a4280fd3360] | committer: Hugo Beauzée-Luyssen

addons: Don't keep an incomplete file on error

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

 modules/misc/addons/fsstorage.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/modules/misc/addons/fsstorage.c b/modules/misc/addons/fsstorage.c
index 61d374eb00..e4916b099e 100644
--- a/modules/misc/addons/fsstorage.c
+++ b/modules/misc/addons/fsstorage.c
@@ -421,15 +421,15 @@ static int InstallFile( addons_storage_t *p_this, const char *psz_downloadlink,
         if ( fwrite( &buffer, i_read, 1, p_destfile ) < 1 )
         {
             msg_Err( p_this, "Failed to write to Addon file" );
-            fclose( p_destfile );
-            vlc_stream_Delete( p_stream );
-            return VLC_EGENERIC;
+            break;
         }
     }
 
     fclose( p_destfile );
+    if ( i_read < 0 )
+        vlc_unlink( psz_dest );
     vlc_stream_Delete( p_stream );
-    return VLC_SUCCESS;
+    return i_read >= 0 ? VLC_SUCCESS : VLC_EGENERIC;
 }
 
 static int InstallAllFiles( addons_storage_t *p_this, const addon_entry_t *p_entry )



More information about the vlc-commits mailing list