Skip to content

Commit

Permalink
Support setting time in MetaDataBuilder (#124)
Browse files Browse the repository at this point in the history
The time fields (accessed, modified) in MetaData are currently not changeable, but it's supported by the protocol.

Setting time attributes of a file could be useful for many cases, especially to workaround the coarse timestamp granularity (seconds) of sftp. By setting timestamps, we can then tell if a file has been modified within a second.
  • Loading branch information
lnyng committed Jun 27, 2024
1 parent 8a7c0b6 commit f5a0e3f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ impl MetaDataBuilder {
self
}

/// Set accessed and modified time of the metadata to be built.
pub fn time(&mut self, accessed: UnixTimeStamp, modified: UnixTimeStamp) -> &mut Self {
self.0.set_time(accessed.0, modified.0);
self
}

/// Create a [`MetaData`].
pub fn create(&self) -> MetaData {
MetaData::new(self.0)
Expand Down

0 comments on commit f5a0e3f

Please sign in to comment.