Skip to content

Commit 0a0bc89

Browse files
committed
fix: clippy format and empty folder scan error
1 parent 1324f00 commit 0a0bc89

4 files changed

Lines changed: 24 additions & 15 deletions

File tree

src/domain/entity/workspace.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ impl Workspace {
8181
}
8282

8383
/// Strip uri prefix of decoded workspace path
84+
#[cfg(target_os = "windows")]
85+
pub fn strip_decode_path(&self) -> String {
86+
let strip_uri_prefix = Regex::new(r"(file|vscode-remote):[/]+").unwrap();
87+
strip_uri_prefix.replace(&self.decode_path, "").to_string()
88+
}
89+
90+
/// Strip uri prefix of decoded workspace path
91+
#[cfg(target_os = "linux")]
8492
pub fn strip_decode_path(&self) -> String {
8593
let strip_uri_prefix = Regex::new(r"(file|vscode-remote):[/][/]").unwrap();
8694
strip_uri_prefix.replace(&self.decode_path, "").to_string()

src/domain/searching/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl From<&str> for SearchingStrategy {
5555
let tags = tag_re
5656
.captures_iter(origin)
5757
.map(|x| x.get(0).unwrap().as_str())
58-
.map(|x| x.to_string().replace(' ', "").replace('#', ""))
58+
.map(|x| x.to_string().replace([' ', '#'], ""))
5959
.filter(|x| !x.is_empty())
6060
.collect::<Vec<String>>();
6161

src/domain/system/folder_observer.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ pub fn last_modified(workspace: &Workspace) -> Result<String, SystemError> {
1414
let mut entries = result?;
1515
entries.sort_by_cached_key(|f| f.metadata().unwrap().modified().unwrap());
1616

17-
let last_modified_secs = entries[0]
18-
.metadata()
19-
.unwrap()
20-
.modified()
21-
.unwrap()
22-
.duration_since(UNIX_EPOCH)
23-
.unwrap()
24-
.as_secs();
17+
let last_modified_secs = if !(entries.is_empty()) {
18+
entries[0]
19+
.metadata()
20+
.unwrap()
21+
.modified()
22+
.unwrap()
23+
.duration_since(UNIX_EPOCH)
24+
.unwrap()
25+
.as_secs()
26+
} else {
27+
0u64
28+
};
2529

2630
Ok(Utc
2731
.timestamp_opt(last_modified_secs as i64, 0)

src/domain/system/scan.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,9 @@ pub fn scan_workspaces_path() -> Vec<Workspace> {
3838
for json_path in current_workspaces_list.unwrap() {
3939
let data = extract_json_file(json_path.as_str());
4040

41-
match data {
42-
Some(val) => {
43-
s.send(Some(Workspace::from(val)))
44-
.expect("Fail to send Workspace struct to main receive channel.");
45-
}
46-
None => {}
41+
if let Some(val) = data {
42+
s.send(Some(Workspace::from(val)))
43+
.expect("Fail to send Workspace struct to main receive channel.");
4744
}
4845
}
4946
});

0 commit comments

Comments
 (0)