lib/repo: Port bareuser-conversion stat to bare load
authorColin Walters <walters@verbum.org>
Thu, 29 Jun 2017 01:50:10 +0000 (21:50 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 29 Jun 2017 15:07:49 +0000 (15:07 +0000)
I noticed this is a simple call that's useful to port to the new internal-only
non-allocating API.

Closes: #977
Approved by: jlebon

src/libostree/ostree-repo.c

index 20f866b9d4e17c13c5c7bed7a5de9c977ecbce1e..a53a056e95d7359b0575b53ab87adc7444a7092d 100644 (file)
@@ -3074,25 +3074,24 @@ import_one_object_link (OstreeRepo    *self,
    */
   if (import_is_bareuser_only_conversion (source, self, objtype))
     {
-      g_autoptr(GFileInfo) finfo = NULL;
+      struct stat stbuf;
 
-      if (!ostree_repo_load_file (source, checksum, NULL, &finfo, NULL,
-                                  cancellable, error))
+      if (!_ostree_repo_load_file_bare (source, checksum, NULL, &stbuf,
+                                        NULL, NULL, cancellable, error))
         return FALSE;
 
-      switch (g_file_info_get_file_type (finfo))
+      if (S_ISREG (stbuf.st_mode))
         {
-        case G_FILE_TYPE_REGULAR:
           /* This is OK, we'll drop through and try a hardlink */
-          break;
-        case G_FILE_TYPE_SYMBOLIC_LINK:
+        }
+      else if (S_ISLNK (stbuf.st_mode))
+        {
           /* NOTE early return */
           *out_was_supported = FALSE;
           return TRUE;
-        default:
-          g_assert_not_reached ();
-          break;
         }
+      else
+        g_assert_not_reached ();
     }
 
   if (!_ostree_repo_ensure_loose_objdir_at (self->objects_dir_fd, loose_path_buf, cancellable, error))