fix file created_at not working on some targets
This commit is contained in:
5
backend/Cargo.lock
generated
5
backend/Cargo.lock
generated
@@ -1662,9 +1662,9 @@ checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustix"
|
name = "rustix"
|
||||||
version = "1.0.7"
|
version = "1.0.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266"
|
checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"errno",
|
"errno",
|
||||||
@@ -2524,6 +2524,7 @@ dependencies = [
|
|||||||
"hex",
|
"hex",
|
||||||
"mime_guess",
|
"mime_guess",
|
||||||
"regex",
|
"regex",
|
||||||
|
"rustix",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sqlx",
|
"sqlx",
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ dotenv = "0.15.0"
|
|||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
mime_guess = "2.0.5"
|
mime_guess = "2.0.5"
|
||||||
regex = "1.11.1"
|
regex = "1.11.1"
|
||||||
|
rustix = { version = "1.0.8", features = ["fs"] }
|
||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
serde_json = "1.0.140"
|
serde_json = "1.0.140"
|
||||||
sqlx = { version = "0.8.6", features = ["chrono", "postgres", "runtime-tokio", "time", "uuid"] }
|
sqlx = { version = "0.8.6", features = ["chrono", "postgres", "runtime-tokio", "time", "uuid"] }
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use std::time::UNIX_EPOCH;
|
|
||||||
|
|
||||||
use anyhow::{Context, anyhow, bail};
|
use anyhow::{Context, anyhow, bail};
|
||||||
|
use rustix::fs::statx;
|
||||||
use tokio::{
|
use tokio::{
|
||||||
fs,
|
fs,
|
||||||
io::{self, AsyncWriteExt as _},
|
io::{self, AsyncWriteExt as _},
|
||||||
@@ -72,12 +71,19 @@ impl FileSystem {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let metadata = entry.metadata().await?;
|
|
||||||
let created_at = metadata
|
// TODO: Use `DirEntry::metadata` once `target=x86_64-unknown-linux-musl` updates from musl 1.2.3 to 1.2.5
|
||||||
.created()
|
// https://github.com/rust-lang/rust/pull/142682
|
||||||
.ok()
|
let created_at = unsafe {
|
||||||
.map(|c| c.duration_since(UNIX_EPOCH).ok().map(|c| c.as_secs()))
|
statx(
|
||||||
.flatten();
|
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 {
|
let mime_type = match file_type {
|
||||||
FileType::File => FileMimeType::from_name(&name),
|
FileType::File => FileMimeType::from_name(&name),
|
||||||
|
|||||||
Reference in New Issue
Block a user