From 4456767ec43ad71af5f79747461ed7ac326bf830 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sat, 29 Nov 2025 11:02:27 +0000 Subject: [PATCH] Clean up --- frontend/sync-client/src/file-operations/file-operations.ts | 3 +-- sync-server/src/utils/find_first_available_path.rs | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/frontend/sync-client/src/file-operations/file-operations.ts b/frontend/sync-client/src/file-operations/file-operations.ts index 1cf434c2..42409227 100644 --- a/frontend/sync-client/src/file-operations/file-operations.ts +++ b/frontend/sync-client/src/file-operations/file-operations.ts @@ -251,8 +251,7 @@ export class FileOperations { : ""; let stem = extension ? nameParts.slice(0, -1).join(".") : fileName; let currentCount = Number.parseInt( - FileOperations.PARENTHESES_REGEX.exec(stem)?.groups?.["count"] ?? - "0" + FileOperations.PARENTHESES_REGEX.exec(stem)?.groups?.count ?? "0" ); stem = stem.replace(FileOperations.PARENTHESES_REGEX, ""); diff --git a/sync-server/src/utils/find_first_available_path.rs b/sync-server/src/utils/find_first_available_path.rs index 002c0241..4b5e6b97 100644 --- a/sync-server/src/utils/find_first_available_path.rs +++ b/sync-server/src/utils/find_first_available_path.rs @@ -8,17 +8,15 @@ pub async fn find_first_available_path( database: &crate::app_state::database::Database, transaction: &mut Transaction<'_>, ) -> Result { - let mut new_relative_path = String::default(); for candidate in dedup_paths(sanitized_relative_path) { if database .get_latest_document_by_path(vault_id, &candidate, Some(transaction)) .await? .is_none() { - new_relative_path = candidate; - break; + return Ok(candidate); } } - Ok(new_relative_path) + unreachable!("dedup_paths produces infinite paths"); }