]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pull: honor sync for OCI artifacts
authordongshengyuan <545258830@qq.com>
Fri, 3 Jul 2026 07:17:53 +0000 (15:17 +0800)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 7 Jul 2026 16:43:42 +0000 (18:43 +0200)
Synchronize OCI layer directories and generated metadata
when IMPORT_SYNC is enabled, matching the raw and tar pull paths.

Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
src/import/pull-oci.c

index a9019f19a51c0ec49a2fa4c4d0d7fb302f1f3713..90dfee9ed4a84e04106c7ef9e883ee8c4812a941 100644 (file)
@@ -1067,7 +1067,9 @@ static int oci_pull_save_nspawn_settings(OciPull *i) {
                 fprintf(f, "Parameters=%s\n", ej);
         }
 
-        r = flink_tmpfile(f, tmpfile, j, LINK_TMPFILE_REPLACE);
+        r = flink_tmpfile(f, tmpfile, j,
+                          LINK_TMPFILE_REPLACE|
+                          (i->flags & IMPORT_SYNC ? LINK_TMPFILE_SYNC : 0));
         if (r < 0)
                 return log_error_errno(r, "Failed to move '%s' into place: %m", j);
 
@@ -1099,7 +1101,9 @@ static int oci_pull_save_oci_config(OciPull *i) {
         if (r < 0)
                 return log_error_errno(r, "Failed to write '%s': %m", j);
 
-        r = link_tmpfile(fd, tmpfile, j, LINK_TMPFILE_REPLACE);
+        r = link_tmpfile(fd, tmpfile, j,
+                         LINK_TMPFILE_REPLACE|
+                         (i->flags & IMPORT_SYNC ? LINK_TMPFILE_SYNC : 0));
         if (r < 0)
                 return log_error_errno(r, "Failed to move '%s' into place: %m", j);
 
@@ -1174,8 +1178,13 @@ static int oci_pull_save_mstack(OciPull *i) {
                 }
         }
 
-        if (rename(jt, j) < 0)
-                return log_error_errno(errno, "Failed to move '%s' into place: %m", j);
+        r = install_file(
+                        AT_FDCWD, jt,
+                        AT_FDCWD, j,
+                        (i->flags & IMPORT_FORCE ? INSTALL_REPLACE : 0) |
+                        (i->flags & IMPORT_SYNC ? INSTALL_SYNCFS|INSTALL_GRACEFUL : 0));
+        if (r < 0)
+                return log_error_errno(r, "Failed to move '%s' into place: %m", j);
 
         jt = mfree(jt); /* Disarm rm_rf_physical_and_free() */