From: Filip Schauer <f.schauer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH proxmox 08/26] oci: explicitly set mtime of directories when extracting layer
Date: Thu, 12 Nov 2026 15:10:35 +0100 [thread overview]
Message-ID: <20261112141109.137298-9-f.schauer@proxmox.com> (raw)
In-Reply-To: <20261112141109.137298-1-f.schauer@proxmox.com>
The tar crate doesn't set the mtime of directories when unpacking a TAR
archive, even though preserving mtimes is enabled by default. Therefore
set the mtime manually.
Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
---
| 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
--git a/proxmox-oci/src/extract.rs b/proxmox-oci/src/extract.rs
index d9d5f1b4..b158c3be 100644
--- a/proxmox-oci/src/extract.rs
+++ b/proxmox-oci/src/extract.rs
@@ -1,9 +1,10 @@
use std::ffi::OsStr;
-use std::fs::{read_dir, remove_dir_all, remove_file};
+use std::fs::{File, read_dir, remove_dir_all, remove_file};
use std::io::{self, ErrorKind, Read, Seek, SeekFrom};
use std::os::unix::ffi::OsStrExt;
use std::path::{Path, PathBuf};
use std::str::FromStr;
+use std::time::{Duration, UNIX_EPOCH};
use flate2::read::GzDecoder;
use oci_spec::image::{ImageConfiguration, ImageManifest, MediaType};
@@ -249,14 +250,32 @@ fn extract_archive<R: Read>(reader: &mut R, target_path: &Path) -> io::Result<()
// to avoid failure on restrictive parent directory permissions.
directories.sort_by(|a, b| b.path_bytes().cmp(&a.path_bytes()));
for mut dir in directories {
+ let dir_path = dir.path()?.into_owned();
+
// Skip a directory replaced by a later entry, also to not apply it through a symlink.
- if let Some(dir_path_abs) = resolve_in_target(target_path, &dir.path()?)?
+ if let Some(dir_path_abs) = resolve_in_target(target_path, &dir_path)?
&& dir_path_abs.symlink_metadata().is_ok_and(|m| !m.is_dir())
{
continue;
}
- dir.unpack_in(target_path)?;
+ if !dir.unpack_in(target_path)? {
+ continue;
+ }
+
+ // Manually set the mtime of the directory, since tar-rs doesn't do it.
+ if let Ok(mtime) = dir.header().mtime()
+ && let Some(dir_path_abs) = resolve_dir_in_target(target_path, &dir_path)?
+ {
+ let secs = mtime.cast_signed();
+ let duration = Duration::from_secs(secs.unsigned_abs());
+ let mtime = if secs > 0 {
+ UNIX_EPOCH + duration
+ } else {
+ UNIX_EPOCH - duration
+ };
+ File::open(dir_path_abs)?.set_modified(mtime)?;
+ }
}
Ok(())
--
2.47.3
next prev parent reply other threads:[~2026-11-16 1:29 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 14:10 [PATCH container/manager/proxmox{,-perl-rs}/storage 00/26] oci: add native registry client and prepare for OverlayFS Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox-perl-rs 01/26] pve-rs: oci: update doc comment of parse_and_extract_image Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 02/26] oci: rename error when no manifest can be selected Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 03/26] oci: add `os` parameter to parse_and_extract_image Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox-perl-rs 04/26] pve-rs: " Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 05/26] oci: add a digest helper module Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 06/26] oci: reduce redundant layer decompression during extraction Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 07/26] oci: factor out parsing and extraction into modules Filip Schauer
2026-11-12 14:10 ` Filip Schauer [this message]
2026-11-12 14:10 ` [PATCH proxmox 09/26] oci: add a registry client Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 10/26] oci: add a public list_repository_tags function Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox-perl-rs 11/26] pve-rs: oci: expose list_repository_tags Filip Schauer
2026-11-12 14:10 ` [PATCH manager 12/26] use proxmox-oci instead of skopeo for listing tags from OCI registries Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 13/26] oci: rename parse_and_extract_image to be tar-specific Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox-perl-rs 14/26] pve-rs: " Filip Schauer
2026-11-12 14:10 ` [PATCH container 15/26] oci create: " Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 16/26] oci: rename ProxmoxOciError to ParseAndExtractTarError Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 17/26] oci: add a public pull_image_as_tar function Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox-perl-rs 18/26] pve-rs: oci: expose pull_image_as_tar Filip Schauer
2026-11-12 14:10 ` [PATCH storage 19/26] use proxmox-oci instead of skopeo for pulling from OCI registries Filip Schauer
2026-11-12 14:10 ` [PATCH storage 20/26] api: oci image pull: fix temp file cleanup on task stop Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 21/26] oci: add a public pull_image_to_oci_storage function Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox-perl-rs 22/26] pve-rs: oci: expose pull_image_to_oci_storage Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 23/26] fix #7058: oci: add compatibility for Docker Image Manifest V2 Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 24/26] oci: include media type in ParseError::WrongMediaType Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 25/26] oci: add public functions for removing OCI images Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox-perl-rs 26/26] pve-rs: oci: expose " Filip Schauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261112141109.137298-9-f.schauer@proxmox.com \
--to=f.schauer@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox