Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add real values for file atime, ctime, and mtime #48

Merged
merged 3 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions s3-client/src/mock_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ impl MockClient {
pub struct MockObject {
generator: Box<dyn Fn(u64, usize) -> Box<[u8]> + Send + Sync>,
size: usize,
pub last_modified: OffsetDateTime,
}

impl MockObject {
Expand All @@ -84,13 +85,15 @@ impl MockObject {
Self {
size: bytes.len(),
generator: Box::new(move |offset, size| bytes[offset as usize..offset as usize + size].into()),
last_modified: OffsetDateTime::now_utc(),
}
}

pub fn constant(v: u8, size: usize) -> Self {
Self {
generator: Box::new(move |_offset, size| vec![v; size].into_boxed_slice()),
size,
last_modified: OffsetDateTime::now_utc(),
}
}

Expand All @@ -108,9 +111,14 @@ impl MockObject {
vec.into_boxed_slice()
}),
size,
last_modified: OffsetDateTime::now_utc(),
}
}

pub fn set_last_modified(&mut self, last_modified: OffsetDateTime) {
self.last_modified = last_modified;
}

pub fn len(&self) -> usize {
self.size
}
Expand Down Expand Up @@ -244,8 +252,7 @@ impl ObjectClient for MockClient {
object: ObjectInfo {
key: key.to_string(),
size: object.size as u64,
// TODO real mtimes
last_modified: OffsetDateTime::from_unix_timestamp(0).unwrap(),
last_modified: object.last_modified,
etag: "TODO".to_string(),
storage_class: None,
},
Expand Down Expand Up @@ -283,7 +290,7 @@ impl ObjectClient for MockClient {
// start at the beginning of the bucket.
let object_iterator = objects.range(continuation_token.unwrap_or("").to_string()..);

for (key, value) in object_iterator {
for (key, object) in object_iterator {
// If the prefix is `n` characters long, and we encounter a key whose first `n`
// characters are lexicographically larger than the prefix, then we can stop iterating.
// Note that we cannot just do a direct comparison between the full key and prefix. For
Expand Down Expand Up @@ -340,9 +347,8 @@ impl ObjectClient for MockClient {
} else {
object_vec.push(ObjectInfo {
key: key.to_string(),
size: value.len() as u64,
// TODO real mtimes
last_modified: OffsetDateTime::from_unix_timestamp(0).unwrap(),
size: object.len() as u64,
last_modified: object.last_modified,
etag: "TODO".to_string(),
storage_class: None,
});
Expand Down
1 change: 1 addition & 0 deletions s3-file-connector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ thiserror = "1.0.34"
tracing = { version = "0.1.35", default-features = false, features = ["std", "log"] }
tracing-subscriber = { version = "0.3.14", features = ["fmt", "env-filter"] }
nix = { version = "0.26.1", default-features = false, features = ["user"] }
time = "0.3.17"

[dev-dependencies]
assert_cmd = "2.0.6"
Expand Down
6 changes: 3 additions & 3 deletions s3-file-connector/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ where
ino,
size: stat.size as u64,
blocks: stat.size as u64 / BLOCK_SIZE,
atime: UNIX_EPOCH,
mtime: UNIX_EPOCH, // TODO
ctime: UNIX_EPOCH,
atime: stat.atime.into(),
mtime: stat.mtime.into(),
ctime: stat.ctime.into(),
crtime: UNIX_EPOCH,
kind: (&stat.kind).into(),
perm,
Expand Down
Loading