lib: Define an alias OSTREE_REPO_MODE_ARCHIVE
authorColin Walters <walters@verbum.org>
Thu, 21 Sep 2017 19:48:46 +0000 (15:48 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 21 Sep 2017 22:17:55 +0000 (22:17 +0000)
For the old `OSTREE_REPO_MODE_ARCHIVE_Z2`.  Use it mostly tree
wide except for the repo finder tests (to avoid conflicting with
some outstanding PRs).

Just noted another user coming in some of those tests and wanted to do a
cleanup.

Closes: #1209
Approved by: jlebon

src/libostree/ostree-core.c
src/libostree/ostree-core.h
src/libostree/ostree-repo-checkout.c
src/libostree/ostree-repo-commit.c
src/libostree/ostree-repo-pull.c
src/libostree/ostree-repo.c

index c81aa39cb7127a43008ee4efb1e39371d2140e03..5a4b58f46df5b89966c446cb9ea5a60428f5d2ca 100644 (file)
@@ -35,6 +35,7 @@
 /* Generic ABI checks */
 G_STATIC_ASSERT(OSTREE_REPO_MODE_BARE == 0);
 G_STATIC_ASSERT(OSTREE_REPO_MODE_ARCHIVE_Z2 == 1);
+G_STATIC_ASSERT(OSTREE_REPO_MODE_ARCHIVE == OSTREE_REPO_MODE_ARCHIVE_Z2);
 G_STATIC_ASSERT(OSTREE_REPO_MODE_BARE_USER == 2);
 G_STATIC_ASSERT(OSTREE_REPO_MODE_BARE_USER_ONLY == 3);
 
@@ -1530,7 +1531,7 @@ _ostree_loose_path (char              *buf,
   buf++;
   snprintf (buf, _OSTREE_LOOSE_PATH_MAX - 2, "/%s.%s%s",
             checksum + 2, ostree_object_type_to_string (objtype),
-            (!OSTREE_OBJECT_TYPE_IS_META (objtype) && mode == OSTREE_REPO_MODE_ARCHIVE_Z2) ? "z" : "");
+            (!OSTREE_OBJECT_TYPE_IS_META (objtype) && mode == OSTREE_REPO_MODE_ARCHIVE) ? "z" : "");
 }
 
 /**
index 5124814cdf35ae08c97e3b67fb9149983223dc06..aae86d548193ea67c45edf003f6fda79062ee85a 100644 (file)
@@ -180,7 +180,8 @@ typedef enum {
 /**
  * OstreeRepoMode:
  * @OSTREE_REPO_MODE_BARE: Files are stored as themselves; checkouts are hardlinks; can only be written as root
- * @OSTREE_REPO_MODE_ARCHIVE_Z2: Files are compressed, should be owned by non-root.  Can be served via HTTP
+ * @OSTREE_REPO_MODE_ARCHIVE: Files are compressed, should be owned by non-root.  Can be served via HTTP.  Since: 2017.12
+ * @OSTREE_REPO_MODE_ARCHIVE_Z2: Legacy alias for `OSTREE_REPO_MODE_ARCHIVE`
  * @OSTREE_REPO_MODE_BARE_USER: Files are stored as themselves, except ownership; can be written by user. Hardlinks work only in user checkouts.
  * @OSTREE_REPO_MODE_BARE_USER_ONLY: Same as BARE_USER, but all metadata is not stored, so it can only be used for user checkouts. Does not need xattrs.
  *
@@ -189,7 +190,8 @@ typedef enum {
  */
 typedef enum {
   OSTREE_REPO_MODE_BARE,
-  OSTREE_REPO_MODE_ARCHIVE_Z2,
+  OSTREE_REPO_MODE_ARCHIVE,
+  OSTREE_REPO_MODE_ARCHIVE_Z2 = OSTREE_REPO_MODE_ARCHIVE,
   OSTREE_REPO_MODE_BARE_USER,
   OSTREE_REPO_MODE_BARE_USER_ONLY,
 } OstreeRepoMode;
index fd1153ac3710767c6c7b986a45aaebf32fa04d25..a3dd68878cbe3ae3fd588390a95916ec87716efe 100644 (file)
@@ -536,7 +536,7 @@ checkout_one_file_at (OstreeRepo                        *repo,
             (repo_is_usermode && options->mode == OSTREE_REPO_CHECKOUT_MODE_USER);
           gboolean current_can_cache = (options->enable_uncompressed_cache
                                         && current_repo->enable_uncompressed_cache);
-          gboolean is_archive_z2_with_cache = (current_repo->mode == OSTREE_REPO_MODE_ARCHIVE_Z2
+          gboolean is_archive_z2_with_cache = (current_repo->mode == OSTREE_REPO_MODE_ARCHIVE
                                                && options->mode == OSTREE_REPO_CHECKOUT_MODE_USER
                                                && current_can_cache);
 
@@ -608,7 +608,7 @@ checkout_one_file_at (OstreeRepo                        *repo,
       && !is_whiteout
       && !is_symlink
       && need_copy
-      && repo->mode == OSTREE_REPO_MODE_ARCHIVE_Z2
+      && repo->mode == OSTREE_REPO_MODE_ARCHIVE
       && options->mode == OSTREE_REPO_CHECKOUT_MODE_USER)
     {
       HardlinkResult hardlink_res = HARDLINK_RESULT_NOT_SUPPORTED;
index a85da1c3be70a31d29fd0e4dc5b979cb42fb6d46..2268c0ff64e3622ee59d6289c5cb731520392f3d 100644 (file)
@@ -215,7 +215,7 @@ commit_loose_regfile_object (OstreeRepo        *self,
   /* We may be writing as root to a non-root-owned repository; if so,
    * automatically inherit the non-root ownership.
    */
-  if (self->mode == OSTREE_REPO_MODE_ARCHIVE_Z2
+  if (self->mode == OSTREE_REPO_MODE_ARCHIVE
       && self->target_owner_uid != -1)
     {
       if (fchown (tmpf->fd, self->target_owner_uid, self->target_owner_gid) < 0)
@@ -603,7 +603,7 @@ write_content_object (OstreeRepo         *self,
                                               cancellable, error))
         return FALSE;
     }
-  else if (repo_mode != OSTREE_REPO_MODE_ARCHIVE_Z2)
+  else if (repo_mode != OSTREE_REPO_MODE_ARCHIVE)
     {
       if (!create_regular_tmpfile_linkable_with_content (self, size, file_input,
                                                          &tmpf, cancellable, error))
@@ -616,7 +616,7 @@ write_content_object (OstreeRepo         *self,
       g_autoptr(GOutputStream) compressed_out_stream = NULL;
       g_autoptr(GOutputStream) temp_out = NULL;
 
-      g_assert (repo_mode == OSTREE_REPO_MODE_ARCHIVE_Z2);
+      g_assert (repo_mode == OSTREE_REPO_MODE_ARCHIVE);
 
       if (self->generate_sizes)
         indexable = TRUE;
@@ -932,7 +932,7 @@ scan_one_loose_devino (OstreeRepo                     *self,
           gboolean skip;
           switch (self->mode)
             {
-            case OSTREE_REPO_MODE_ARCHIVE_Z2:
+            case OSTREE_REPO_MODE_ARCHIVE:
             case OSTREE_REPO_MODE_BARE:
             case OSTREE_REPO_MODE_BARE_USER:
             case OSTREE_REPO_MODE_BARE_USER_ONLY:
@@ -981,7 +981,7 @@ scan_loose_devino (OstreeRepo                     *self,
         return FALSE;
     }
 
-  if (self->mode == OSTREE_REPO_MODE_ARCHIVE_Z2)
+  if (self->mode == OSTREE_REPO_MODE_ARCHIVE)
     {
       if (!scan_one_loose_devino (self, self->uncompressed_objects_dir_fd, devino_cache,
                                   cancellable, error))
index a32f67410b0505332ba034e9fc0316e932d40dfc..d8048e757e4b905e7d7512dc689b0f8eddf8b67e 100644 (file)
@@ -1029,7 +1029,7 @@ content_fetch_on_complete (GObject        *object,
    * the content rather than paying the cost of exploding it, checksumming, and
    * re-gzip.
    */
-  if (pull_data->is_mirror && pull_data->repo->mode == OSTREE_REPO_MODE_ARCHIVE_Z2
+  if (pull_data->is_mirror && pull_data->repo->mode == OSTREE_REPO_MODE_ARCHIVE
       && !pull_data->is_bareuseronly_files)
     {
       gboolean have_object;
@@ -3529,7 +3529,7 @@ ostree_repo_pull_with_options (OstreeRepo             *self,
                                                 &pull_data->has_tombstone_commits, error))
         goto out;
 
-      if (pull_data->remote_mode != OSTREE_REPO_MODE_ARCHIVE_Z2)
+      if (pull_data->remote_mode != OSTREE_REPO_MODE_ARCHIVE)
         {
           g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                        "Can't pull from archives with mode \"%s\"",
@@ -3550,7 +3550,7 @@ ostree_repo_pull_with_options (OstreeRepo             *self,
     }
 
   /* We can't use static deltas if pulling into an archive repo. */
-  if (self->mode == OSTREE_REPO_MODE_ARCHIVE_Z2)
+  if (self->mode == OSTREE_REPO_MODE_ARCHIVE)
     {
       if (pull_data->require_static_deltas)
         {
@@ -4894,7 +4894,7 @@ find_remotes_cb (GObject      *obj,
       if (commit_metadata->timestamp != 0)
         continue;
 
-      _ostree_loose_path (buf, commit_metadata->checksum, OSTREE_OBJECT_TYPE_COMMIT, OSTREE_REPO_MODE_ARCHIVE_Z2);
+      _ostree_loose_path (buf, commit_metadata->checksum, OSTREE_OBJECT_TYPE_COMMIT, OSTREE_REPO_MODE_ARCHIVE);
       commit_filename = g_build_filename ("objects", buf, NULL);
 
       /* For each of the remotes whose summary files contain this ref, try
index e2e91621363cd955229cc27ad78a9139e6da9a8e..82c01e05ae45ce51ef0bff74037213f8b71365ff 100644 (file)
@@ -1749,7 +1749,8 @@ ostree_repo_mode_to_string (OstreeRepoMode   mode,
     case OSTREE_REPO_MODE_BARE_USER_ONLY:
       ret_mode = "bare-user-only";
       break;
-    case OSTREE_REPO_MODE_ARCHIVE_Z2:
+    case OSTREE_REPO_MODE_ARCHIVE:
+      /* Legacy alias */
       ret_mode ="archive-z2";
       break;
     default:
@@ -1775,7 +1776,7 @@ ostree_repo_mode_from_string (const char      *mode,
     ret_mode = OSTREE_REPO_MODE_BARE_USER_ONLY;
   else if (strcmp (mode, "archive-z2") == 0 ||
            strcmp (mode, "archive") == 0)
-    ret_mode = OSTREE_REPO_MODE_ARCHIVE_Z2;
+    ret_mode = OSTREE_REPO_MODE_ARCHIVE;
   else
     return glnx_throw (error, "Invalid mode '%s' in repository configuration", mode);
 
@@ -2473,7 +2474,7 @@ ostree_repo_open (OstreeRepo    *self,
     return FALSE;
 
   /* TODO - delete this */
-  if (self->mode == OSTREE_REPO_MODE_ARCHIVE_Z2 && self->enable_uncompressed_cache)
+  if (self->mode == OSTREE_REPO_MODE_ARCHIVE && self->enable_uncompressed_cache)
     {
       if (!glnx_shutil_mkdir_p_at (self->repo_dir_fd, "uncompressed-objects-cache", 0755,
                                    cancellable, error))
@@ -2724,7 +2725,7 @@ list_loose_objects_at (OstreeRepo             *self,
         continue;
 
       OstreeObjectType objtype;
-      if ((self->mode == OSTREE_REPO_MODE_ARCHIVE_Z2
+      if ((self->mode == OSTREE_REPO_MODE_ARCHIVE
            && strcmp (dot, ".filez") == 0) ||
           ((_ostree_repo_mode_is_bare (self->mode))
            && strcmp (dot, ".file") == 0))
@@ -3150,7 +3151,7 @@ ostree_repo_load_file (OstreeRepo         *self,
                        GCancellable       *cancellable,
                        GError            **error)
 {
-  if (self->mode == OSTREE_REPO_MODE_ARCHIVE_Z2)
+  if (self->mode == OSTREE_REPO_MODE_ARCHIVE)
     return repo_load_file_archive (self, checksum, out_input, out_file_info, out_xattrs,
                                    cancellable, error);
   else