registry: don't forget to clean up registry temp file in another error case
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Fri, 24 Feb 2012 23:19:51 +0000 (23:19 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Fri, 24 Feb 2012 23:49:54 +0000 (23:49 +0000)
Also clean up temp file if we get an error during write() rather
than just when doing fsync() or close().

gst/gstregistrybinary.c

index 1a58837..7cd148e 100644 (file)
@@ -245,12 +245,13 @@ gst_registry_binary_cache_finish (BinaryRegistryCache * cache, gboolean success)
   if (close (cache->cache_fd) < 0)
     goto close_failed;
 
-  if (success) {
-    /* Only do the rename if we wrote the entire file successfully */
-    if (g_rename (cache->tmp_location, cache->location) < 0) {
-      GST_ERROR ("g_rename() failed: %s", g_strerror (errno));
-      goto rename_failed;
-    }
+  if (!success)
+    goto fail_after_close;
+
+  /* Only do the rename if we wrote the entire file successfully */
+  if (g_rename (cache->tmp_location, cache->location) < 0) {
+    GST_ERROR ("g_rename() failed: %s", g_strerror (errno));
+    goto rename_failed;
   }
 
   g_free (cache->tmp_location);