[ostree] core: Call fdatasync() before we rename()



commit 2b90e987bff45dea9f8f0df7876affdc7a9286c7
Author: Colin Walters <walters verbum org>
Date:   Sun Oct 14 15:34:33 2012 -0400

    core: Call fdatasync() before we rename()
    
    Just noticed this from strace, doesn't really matter, but looks nicer.

 src/libostree/ostree-repo.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index 020a595..4033f29 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -3171,6 +3171,12 @@ checkout_file_from_input (GFile          *file,
                                                    cancellable, error))
             goto out;
 
+          if (g_file_info_get_file_type (temp_info) == G_FILE_TYPE_REGULAR)
+            {
+              if (!ensure_file_data_synced (temp_file, cancellable, error))
+                goto out;
+            }
+
           if (rename (ot_gfile_get_path_cached (temp_file), ot_gfile_get_path_cached (file)) < 0)
             {
               ot_util_set_error_from_errno (error, errno);
@@ -3183,12 +3189,12 @@ checkout_file_from_input (GFile          *file,
       if (!ostree_create_file_from_input (file, temp_info,
                                           xattrs, input, cancellable, error))
         goto out;
-    }
 
-  if (g_file_info_get_file_type (temp_info) == G_FILE_TYPE_REGULAR)
-    {
-      if (!ensure_file_data_synced (file, cancellable, error))
-        goto out;
+      if (g_file_info_get_file_type (temp_info) == G_FILE_TYPE_REGULAR)
+        {
+          if (!ensure_file_data_synced (temp_file, cancellable, error))
+            goto out;
+        }
     }
 
   ret = TRUE;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]