Don't crash when modified time of file is before unix epoch
This commit is contained in:
parent
1829d19b28
commit
a0c99ab14b
|
@ -207,7 +207,13 @@ impl BigFile {
|
|||
path: current_file_name.clone(),
|
||||
size: metadata.len(),
|
||||
modified_date: match metadata.modified() {
|
||||
Ok(t) => t.duration_since(UNIX_EPOCH).expect("Invalid file date").as_secs(),
|
||||
Ok(t) => match t.duration_since(UNIX_EPOCH) {
|
||||
Ok(d) => d.as_secs(),
|
||||
Err(_) => {
|
||||
self.text_messages.warnings.push(format!("File {} seems to be modified before Unix Epoch.", current_file_name));
|
||||
0
|
||||
}
|
||||
},
|
||||
Err(_) => {
|
||||
self.text_messages.warnings.push("Unable to get modification date from file ".to_string() + current_file_name.as_str());
|
||||
continue;
|
||||
|
|
|
@ -286,7 +286,13 @@ impl DuplicateFinder {
|
|||
path: current_file_name.clone(),
|
||||
size: metadata.len(),
|
||||
modified_date: match metadata.modified() {
|
||||
Ok(t) => t.duration_since(UNIX_EPOCH).expect("Invalid file date").as_secs(),
|
||||
Ok(t) => match t.duration_since(UNIX_EPOCH) {
|
||||
Ok(d) => d.as_secs(),
|
||||
Err(_) => {
|
||||
self.text_messages.warnings.push(format!("File {} seems to be modified before Unix Epoch.", current_file_name));
|
||||
0
|
||||
}
|
||||
},
|
||||
Err(_) => {
|
||||
self.text_messages.warnings.push("Unable to get modification date from file ".to_string() + current_file_name.as_str());
|
||||
continue;
|
||||
|
|
|
@ -232,7 +232,13 @@ impl EmptyFiles {
|
|||
let fe: FileEntry = FileEntry {
|
||||
path: current_file_name.clone(),
|
||||
modified_date: match metadata.modified() {
|
||||
Ok(t) => t.duration_since(UNIX_EPOCH).expect("Invalid file date").as_secs(),
|
||||
Ok(t) => match t.duration_since(UNIX_EPOCH) {
|
||||
Ok(d) => d.as_secs(),
|
||||
Err(_) => {
|
||||
self.text_messages.warnings.push(format!("File {} seems to be modified before Unix Epoch.", current_file_name));
|
||||
0
|
||||
}
|
||||
},
|
||||
Err(_) => {
|
||||
self.text_messages.warnings.push("Unable to get modification date from file ".to_string() + current_file_name.as_str());
|
||||
continue;
|
||||
|
|
|
@ -182,7 +182,13 @@ impl EmptyFolder {
|
|||
parent_path: Option::from(current_folder.clone()),
|
||||
is_empty: FolderEmptiness::Maybe,
|
||||
modified_date: match metadata.modified() {
|
||||
Ok(t) => t.duration_since(UNIX_EPOCH).expect("Invalid file date").as_secs(),
|
||||
Ok(t) => match t.duration_since(UNIX_EPOCH) {
|
||||
Ok(d) => d.as_secs(),
|
||||
Err(_) => {
|
||||
self.text_messages.warnings.push(format!("Folder {} seems to be modified before Unix Epoch.", current_folder));
|
||||
0
|
||||
}
|
||||
},
|
||||
Err(_) => {
|
||||
self.text_messages.warnings.push(format!("Failed to read modification date of folder {}", current_folder));
|
||||
continue;
|
||||
|
|
|
@ -222,7 +222,13 @@ impl Temporary {
|
|||
let fe: FileEntry = FileEntry {
|
||||
path: current_file_name.clone(),
|
||||
modified_date: match metadata.modified() {
|
||||
Ok(t) => t.duration_since(UNIX_EPOCH).expect("Invalid file date").as_secs(),
|
||||
Ok(t) => match t.duration_since(UNIX_EPOCH) {
|
||||
Ok(d) => d.as_secs(),
|
||||
Err(_) => {
|
||||
self.text_messages.warnings.push(format!("File {} seems to be modified before Unix Epoch.", current_file_name));
|
||||
0
|
||||
}
|
||||
},
|
||||
Err(_) => {
|
||||
self.text_messages.warnings.push("Unable to get modification date from file ".to_string() + current_file_name.as_str());
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue