From: dongshengyuan <545258830@qq.com> Date: Fri, 3 Jul 2026 07:17:53 +0000 (+0800) Subject: pull: honor sync for OCI artifacts X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d8c1f1d105e6313fabf843276bbc5c980f619e43;p=thirdparty%2Fsystemd.git pull: honor sync for OCI artifacts Synchronize OCI layer directories and generated metadata when IMPORT_SYNC is enabled, matching the raw and tar pull paths. Signed-off-by: dongshengyuan --- diff --git a/src/import/pull-oci.c b/src/import/pull-oci.c index a9019f19a51..90dfee9ed4a 100644 --- a/src/import/pull-oci.c +++ b/src/import/pull-oci.c @@ -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() */