mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-15 16:53:25 +00:00
working_copy: avoid using file_state() for getting mtime of tree_state file
I want to change the signature of `file_state()` and this caller is different from the others and only needs the mtime.
This commit is contained in:
parent
efe7316354
commit
5dce6e9884
1 changed files with 7 additions and 12 deletions
|
@ -59,14 +59,6 @@ pub struct FileState {
|
|||
}
|
||||
|
||||
impl FileState {
|
||||
fn null() -> FileState {
|
||||
FileState {
|
||||
file_type: FileType::Normal { executable: false },
|
||||
mtime: MillisSinceEpoch(0),
|
||||
size: 0,
|
||||
}
|
||||
}
|
||||
|
||||
fn mark_executable(&mut self, executable: bool) {
|
||||
if let FileType::Normal { .. } = &self.file_type {
|
||||
self.file_type = FileType::Normal { executable }
|
||||
|
@ -192,10 +184,13 @@ impl TreeState {
|
|||
}
|
||||
|
||||
fn update_read_time(&mut self) {
|
||||
let own_file_state = self
|
||||
.file_state(&self.state_path.join("tree_state"))
|
||||
.unwrap_or_else(FileState::null);
|
||||
self.read_time = own_file_state.mtime;
|
||||
if let Ok(metadata) = self.state_path.join("tree_state").symlink_metadata() {
|
||||
let time = metadata.modified().unwrap();
|
||||
let since_epoch = time.duration_since(UNIX_EPOCH).unwrap();
|
||||
self.read_time = MillisSinceEpoch(since_epoch.as_millis().try_into().unwrap());
|
||||
} else {
|
||||
self.read_time = MillisSinceEpoch(0);
|
||||
}
|
||||
}
|
||||
|
||||
fn read(&mut self, mut file: File) {
|
||||
|
|
Loading…
Reference in a new issue