diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 15f74e7..d12ebd8 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -1662,9 +1662,9 @@ checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f" [[package]] name = "rustix" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" +checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8" dependencies = [ "bitflags", "errno", @@ -2524,6 +2524,7 @@ dependencies = [ "hex", "mime_guess", "regex", + "rustix", "serde", "serde_json", "sqlx", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index e3b965f..ddd7c8e 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -22,6 +22,7 @@ dotenv = "0.15.0" hex = "0.4.3" mime_guess = "2.0.5" regex = "1.11.1" +rustix = { version = "1.0.8", features = ["fs"] } serde = { version = "1.0.219", features = ["derive"] } serde_json = "1.0.140" sqlx = { version = "0.8.6", features = ["chrono", "postgres", "runtime-tokio", "time", "uuid"] } diff --git a/backend/src/lib/outbound/file_system.rs b/backend/src/lib/outbound/file_system.rs index ba4cf1b..41eb5ff 100644 --- a/backend/src/lib/outbound/file_system.rs +++ b/backend/src/lib/outbound/file_system.rs @@ -1,6 +1,5 @@ -use std::time::UNIX_EPOCH; - use anyhow::{Context, anyhow, bail}; +use rustix::fs::statx; use tokio::{ fs, io::{self, AsyncWriteExt as _}, @@ -72,12 +71,19 @@ impl FileSystem { continue; } }; - let metadata = entry.metadata().await?; - let created_at = metadata - .created() - .ok() - .map(|c| c.duration_since(UNIX_EPOCH).ok().map(|c| c.as_secs())) - .flatten(); + + // TODO: Use `DirEntry::metadata` once `target=x86_64-unknown-linux-musl` updates from musl 1.2.3 to 1.2.5 + // https://github.com/rust-lang/rust/pull/142682 + let created_at = unsafe { + statx( + std::os::fd::BorrowedFd::borrow_raw(-100), + entry.path(), + rustix::fs::AtFlags::empty(), + rustix::fs::StatxFlags::BTIME, + ) + } + .ok() + .map(|statx| statx.stx_btime.tv_sec as u64); let mime_type = match file_type { FileType::File => FileMimeType::from_name(&name),