fix(core): resolve all Clippy warnings
- Replace redundant closures with function references (webdav.rs, sync.rs) - Use is_some_and instead of map_or(false, ...) (sync.rs) - Use map instead of and_then(|x| Some(...)) (sync.rs) - Use if-let instead of single-arm match (webdav.rs)
This commit is contained in:
parent
60fbbd75b8
commit
c32a6fbe8b
|
|
@ -173,7 +173,7 @@ pub fn compute_sync_actions(
|
||||||
|
|
||||||
// Remote present, local gone, base known: local was deleted
|
// Remote present, local gone, base known: local was deleted
|
||||||
(None, Some(_), Some(b)) => {
|
(None, Some(_), Some(b)) => {
|
||||||
let remote_changed = remote.map_or(false, |r| r.size != b.size || r.last_modified.as_deref() != b.modified_at.as_deref());
|
let remote_changed = remote.is_some_and(|r| r.size != b.size || r.last_modified.as_deref() != b.modified_at.as_deref());
|
||||||
if remote_changed {
|
if remote_changed {
|
||||||
// deleted locally + modified remotely -> download (remote wins)
|
// deleted locally + modified remotely -> download (remote wins)
|
||||||
actions.push(SyncAction::Download { path: path.to_string() });
|
actions.push(SyncAction::Download { path: path.to_string() });
|
||||||
|
|
@ -374,9 +374,9 @@ fn scan_dir_recursive(root: &Path, dir: &Path, files: &mut Vec<LocalFileInfo>) -
|
||||||
let data = std::fs::read(&path)?;
|
let data = std::fs::read(&path)?;
|
||||||
let metadata = std::fs::metadata(&path)?;
|
let metadata = std::fs::metadata(&path)?;
|
||||||
let modified = metadata.modified().ok()
|
let modified = metadata.modified().ok()
|
||||||
.and_then(|t| {
|
.map(|t| {
|
||||||
let dt: DateTime<Utc> = t.into();
|
let dt: DateTime<Utc> = t.into();
|
||||||
Some(dt.to_rfc3339())
|
dt.to_rfc3339()
|
||||||
});
|
});
|
||||||
|
|
||||||
files.push(LocalFileInfo {
|
files.push(LocalFileInfo {
|
||||||
|
|
@ -540,7 +540,7 @@ pub async fn sync_workspace(
|
||||||
|
|
||||||
// Save queue with remaining failed actions
|
// Save queue with remaining failed actions
|
||||||
let new_queue = OfflineQueue {
|
let new_queue = OfflineQueue {
|
||||||
operations: failed_actions.iter().map(|a| action_to_queued_op(a)).collect(),
|
operations: failed_actions.iter().map(action_to_queued_op).collect(),
|
||||||
};
|
};
|
||||||
new_queue.save(workspace_path)?;
|
new_queue.save(workspace_path)?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ impl WebDavClient {
|
||||||
// Percent-encode path segments while preserving '/'
|
// Percent-encode path segments while preserving '/'
|
||||||
let encoded: String = path
|
let encoded: String = path
|
||||||
.split('/')
|
.split('/')
|
||||||
.map(|seg| percent_encode(seg))
|
.map(percent_encode)
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join("/");
|
.join("/");
|
||||||
format!("{}/{}", self._base_url, encoded)
|
format!("{}/{}", self._base_url, encoded)
|
||||||
|
|
@ -405,9 +405,8 @@ pub fn load_credentials(domain: &str) -> Result<(String, String)> {
|
||||||
let pass_entry = keyring::Entry::new(&service, "password")
|
let pass_entry = keyring::Entry::new(&service, "password")
|
||||||
.map_err(|e| Error::Credential(format!("Failed to create keyring entry: {}", e)))?;
|
.map_err(|e| Error::Credential(format!("Failed to create keyring entry: {}", e)))?;
|
||||||
|
|
||||||
match (user_entry.get_password(), pass_entry.get_password()) {
|
if let (Ok(user), Ok(pass)) = (user_entry.get_password(), pass_entry.get_password()) {
|
||||||
(Ok(user), Ok(pass)) => return Ok((user, pass)),
|
return Ok((user, pass));
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to env vars for headless/CI environments
|
// Fallback to env vars for headless/CI environments
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue