feat(folders): add rename, missing-folder recovery, and right-click context menu
- Backend: new `rename_folder` command (updates display name only, not path) and `update_folder_path` command (rewrites image paths in DB before reindexing so thumbnails/embeddings are not regenerated unnecessarily) - DB: `rename_folder` and `update_folder_path` helpers; `scan_error` column on folders table to surface indexing failures without silently dropping images - Store: `renameFolder` and `updateFolderPath` actions - Sidebar: right-click context menu on each folder row (Reindex, Rename, Locate Folder, Remove from app); inline rename input on Enter/Escape/blur; missing- folder recovery banner with Locate/Remove; hover icon buttons (reindex + remove with Confirm/Cancel) preserved alongside the context menu
This commit is contained in:
@@ -325,6 +325,20 @@ pub async fn reindex_folder(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn rename_folder(
|
||||
db: State<'_, DbState>,
|
||||
folder_id: i64,
|
||||
new_name: String,
|
||||
) -> Result<(), String> {
|
||||
let new_name = new_name.trim().to_string();
|
||||
if new_name.is_empty() {
|
||||
return Err("Folder name cannot be empty".to_string());
|
||||
}
|
||||
let conn = db.get().map_err(|e| e.to_string())?;
|
||||
db::rename_folder(&conn, folder_id, &new_name).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn update_folder_path(
|
||||
app: AppHandle,
|
||||
|
||||
@@ -1356,6 +1356,14 @@ pub fn get_folders(conn: &Connection) -> Result<Vec<Folder>> {
|
||||
Ok(rows.collect::<rusqlite::Result<Vec<_>>>()?)
|
||||
}
|
||||
|
||||
pub fn rename_folder(conn: &Connection, folder_id: i64, new_name: &str) -> Result<()> {
|
||||
conn.execute(
|
||||
"UPDATE folders SET name = ?2 WHERE id = ?1",
|
||||
params![folder_id, new_name],
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn update_folder_path(conn: &Connection, folder_id: i64, old_path: &str, new_path: &str, new_name: &str) -> Result<()> {
|
||||
conn.execute(
|
||||
"UPDATE folders SET path = ?2, name = ?3, scan_error = NULL WHERE id = ?1",
|
||||
|
||||
@@ -133,6 +133,7 @@ pub fn run() {
|
||||
commands::find_duplicates,
|
||||
commands::load_duplicate_scan_cache,
|
||||
commands::delete_images_from_disk,
|
||||
commands::rename_folder,
|
||||
commands::update_folder_path,
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
|
||||
Reference in New Issue
Block a user