LRC-LIB-CATALOG-SWITCH: a library's catalog.snap or folder given at launch opens that library

Double-clicking a library's catalog.snap in Explorer (or giving it, or the
library folder, as an argument) opened the last library used and treated the
argument as photos to import. It now opens that library, through the usual
launch path (the lock check for
one open in another LightCraft), and makes it the library in use. A second
library argument gets a notice. Never imported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

(cherry picked from commit 64a86cf3098ae4d33cef8c4f4a2ec486cdb148a4)
This commit is contained in:
OneSlips
2026-10-26 01:59:34 +10:00
co-authored by Claude Opus 5.5
parent 03c88c166c
commit e47fc37267
3 changed files with 88 additions and 10 deletions
+17
View File
@@ -471,6 +471,20 @@ pub enum LaunchPath {
/// Not imported: `path` (absolute) is a whole drive or the whole home folder, which is never
/// walked without being chosen in the app (issue #374).
Refused { path: String, why: String },
/// Open this (absolute) library folder: the argument was a library's `catalog.snap` or its folder, as a
/// double-click on a catalog in the file manager gives. Never imported.
Library(String),
}
/// The library folder `path` names: a library's `catalog.snap` (its folder), or a folder holding one. `None` for
/// anything else (photos, folders of photos).
pub fn library_dir_of(path: &Path) -> Option<PathBuf> {
let snapshot = lightcraft_catalog::journal::SNAPSHOT;
let named = path.file_name().is_some_and(|n| n.to_string_lossy().eq_ignore_ascii_case(snapshot));
if named && path.is_file() {
return path.parent().map(Path::to_path_buf);
}
(path.is_dir() && path.join(snapshot).is_file()).then(|| path.to_path_buf())
}
/// Resolve a launch argument for importing (issue #374). An empty argument is ignored (`None`);
@@ -514,6 +528,9 @@ pub fn launch_path(arg: &str, cwd: Option<&Path>, home: Option<&Path>, dcim: imp
if home.is_some_and(|h| key(&h.to_string_lossy()) == key(&shown)) {
return Some(LaunchPath::Refused { path: shown, why: "the whole home folder".into() });
}
if let Some(dir) = library_dir_of(&abs) {
return Some(LaunchPath::Library(dir.to_string_lossy().to_string()));
}
Some(LaunchPath::Import(shown))
}