[ostree] core: Only do devino scan on commit (speeds up pull)



commit 52a0b7bdb19d7893c100acb8d378cef41f80990f
Author: Colin Walters <walters verbum org>
Date:   Fri Oct 5 17:12:39 2012 -0400

    core: Only do devino scan on commit (speeds up pull)
    
    When fetching data remotely, there's no point to the devino scan
    because we're not going to be committing local files.
    
    Only do it for "commit".

 src/libostree/ostree-repo.c        |   12 +++++++-----
 src/libostree/ostree-repo.h        |    1 +
 src/ostree/ostree-pull.c           |    2 +-
 src/ostree/ot-builtin-commit.c     |    2 +-
 src/ostree/ot-builtin-pull-local.c |    2 +-
 5 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index ac3a3dc..4081b0b 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -1276,6 +1276,7 @@ devino_cache_lookup (OstreeRepo           *self,
 
 gboolean
 ostree_repo_prepare_transaction (OstreeRepo     *self,
+                                 gboolean        enable_commit_hardlink_scan,
                                  GCancellable   *cancellable,
                                  GError        **error)
 {
@@ -1285,13 +1286,14 @@ ostree_repo_prepare_transaction (OstreeRepo     *self,
 
   self->in_transaction = TRUE;
 
-  if (!self->loose_object_devino_hash)
+  if (enable_commit_hardlink_scan)
     {
-      self->loose_object_devino_hash = g_hash_table_new_full (devino_hash, devino_equal, g_free, g_free);
+      if (!self->loose_object_devino_hash)
+        self->loose_object_devino_hash = g_hash_table_new_full (devino_hash, devino_equal, g_free, g_free);
+      g_hash_table_remove_all (self->loose_object_devino_hash);
+      if (!scan_loose_devino (self, self->loose_object_devino_hash, cancellable, error))
+        goto out;
     }
-  g_hash_table_remove_all (self->loose_object_devino_hash);
-  if (!scan_loose_devino (self, self->loose_object_devino_hash, cancellable, error))
-    goto out;
 
   ret = TRUE;
  out:
diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h
index 2f7ac7a..0ed4c2b 100644
--- a/src/libostree/ostree-repo.h
+++ b/src/libostree/ostree-repo.h
@@ -77,6 +77,7 @@ GFile *       ostree_repo_get_file_object_path (OstreeRepo   *self,
                                                 const char   *object);
 
 gboolean      ostree_repo_prepare_transaction (OstreeRepo     *self,
+                                               gboolean        enable_commit_hardlink_scan,
                                                GCancellable   *cancellable,
                                                GError        **error);
 
diff --git a/src/ostree/ostree-pull.c b/src/ostree/ostree-pull.c
index ccbb003..a618ee9 100644
--- a/src/ostree/ostree-pull.c
+++ b/src/ostree/ostree-pull.c
@@ -1333,7 +1333,7 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
         }
     }
 
-  if (!ostree_repo_prepare_transaction (pull_data->repo, NULL, error))
+  if (!ostree_repo_prepare_transaction (pull_data->repo, FALSE, NULL, error))
     goto out;
 
   pull_data->metadata_scan_active = TRUE;
diff --git a/src/ostree/ot-builtin-commit.c b/src/ostree/ot-builtin-commit.c
index 730e321..96a41eb 100644
--- a/src/ostree/ot-builtin-commit.c
+++ b/src/ostree/ot-builtin-commit.c
@@ -351,7 +351,7 @@ ostree_builtin_commit (int argc, char **argv, GFile *repo_path, GError **error)
         goto out;
     }
 
-  if (!ostree_repo_prepare_transaction (repo, cancellable, error))
+  if (!ostree_repo_prepare_transaction (repo, TRUE, cancellable, error))
     goto out;
 
   in_transaction = TRUE;
diff --git a/src/ostree/ot-builtin-pull-local.c b/src/ostree/ot-builtin-pull-local.c
index 8b7304d..94f0b88 100644
--- a/src/ostree/ot-builtin-pull-local.c
+++ b/src/ostree/ot-builtin-pull-local.c
@@ -196,7 +196,7 @@ ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GError **err
 
   g_print ("%u objects to copy\n", g_hash_table_size (objects_to_copy));
 
-  if (!ostree_repo_prepare_transaction (data.dest_repo, cancellable, error))
+  if (!ostree_repo_prepare_transaction (data.dest_repo, FALSE, cancellable, error))
     goto out;
   
   g_hash_table_iter_init (&hash_iter, objects_to_copy);



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