Skip to content

Commit f5a0e3f

Browse files
authored
Support setting time in MetaDataBuilder (#124)
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.
1 parent 8a7c0b6 commit f5a0e3f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/metadata.rs

+6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ impl MetaDataBuilder {
3737
self
3838
}
3939

40+
/// Set accessed and modified time of the metadata to be built.
41+
pub fn time(&mut self, accessed: UnixTimeStamp, modified: UnixTimeStamp) -> &mut Self {
42+
self.0.set_time(accessed.0, modified.0);
43+
self
44+
}
45+
4046
/// Create a [`MetaData`].
4147
pub fn create(&self) -> MetaData {
4248
MetaData::new(self.0)

0 commit comments

Comments
 (0)