Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
561e5b2
LR-BEHAV-BG-TASKS: a preview build asked for while another runs can w…
nledford Oct 24, 2026
0784cdc
LR-BEHAV-BG-TASKS: a build replaced by the one waiting behind it is s…
nledford Oct 24, 2026
6dd303f
LR-BEHAV-BG-TASKS: the frame that starts a waiting build looks at it …
nledford Oct 26, 2026
ccd0a3b
LR-BEHAV-BG-TASKS: a build asked for without queue does not go ahead …
nledford Oct 26, 2026
67a5f01
LR-BEHAV-BG-TASKS: tests: a started preview build ends before its tes…
nledford Oct 27, 2026
ff7a5fe
LR-BEHAV-BG-TASKS: imports and Synchronize Folder wait for each other…
nledford Oct 15, 2026
a6f87cb
LR-BEHAV-BG-TASKS: a task waiting in line shows in the activity stack…
nledford Oct 24, 2026
2eda69a
LR-BEHAV-BG-TASKS: review fixes: Auto Import waits in line, a waiting…
nledford Oct 24, 2026
c20afd9
LR-BEHAV-BG-TASKS: control-protocol.md says a waiting task has a row …
nledford Oct 26, 2026
abc98ec
LR-BEHAV-BG-TASKS: tests: a waiting synchronize's scan is held open w…
nledford Oct 27, 2026
04707a0
LR-BEHAV-MULTISELECT: several sidebar albums, keywords or folders are…
nledford Oct 11, 2026
7488ac0
LR-BEHAV-MULTISELECT: batch keyword checks fold each path once and us…
nledford Oct 24, 2026
5ab04d7
LR-BEHAV-MULTISELECT: the parity row is partial until the sidebar cal…
nledford Oct 24, 2026
880bf8d
Sidebars: several albums, folders, keywords or dates can be shown at …
nledford Oct 11, 2026
0a47547
Sidebars: gaps.md entry for the sidebar multi-selection still to wire…
nledford Oct 22, 2026
b72bbc7
Sidebars: album.setRules says [] (not null) clears the list fields
nledford Oct 22, 2026
f14eff3
Sidebars: library.filter refuses a single album beside an album source
nledford Oct 22, 2026
69cbc60
Sidebars: a view of albums that are all gone shows All Photos, not an…
nledford Oct 22, 2026
feb4d05
Sidebars: an album filter put aside does not come back beside an albu…
nledford Oct 24, 2026
136a819
Sidebars: deleting every keyword of the filter Enable Filters put asi…
nledford Oct 24, 2026
da9b111
Sidebars: keyword, album and folder chips join their values with the …
nledford Oct 25, 2026
eb91d95
Sidebars: a view of several albums with a smart one among them grays …
nledford Oct 25, 2026
f448e32
Sidebars: a folder filter put aside by Enable Filters follows its fol…
nledford Oct 25, 2026
c903152
Sidebars: the single album of a filter put aside does not come back b…
nledford Oct 26, 2026
7dcbf42
Sidebars: deleting an album takes it out of the filter and the one pu…
nledford Oct 27, 2026
7ca98fe
LR-BEHAV-MULTISELECT: round of 3 Nov: a filter naming a smart album s…
nledford Nov 4, 2026
89fe24f
LR-BEHAV-MULTISELECT: the revision row and What's New lines for the r…
nledford Nov 4, 2026
4c7163c
LR-BEHAV-MULTISELECT: Cmd/Ctrl+click and Shift+click choose several a…
nledford Oct 26, 2026
2a31e8d
LR-BEHAV-MULTISELECT: What's New says Delete once, not among the acti…
nledford Oct 26, 2026
102a4f2
LR-BEHAV-MULTISELECT: Show in Library clears albums and folders in th…
nledford Oct 26, 2026
3508a05
LR-BEHAV-MULTISELECT: a keyword picked in the Keyword List is not pic…
nledford Oct 27, 2026
1b51673
LR-BEHAV-MULTISELECT: port the click selection onto main's ui-egui la…
nledford Nov 2, 2026
639924e
LR-BEHAV-MULTISELECT: the smart-album editor counts within the albums…
nledford Nov 4, 2026
0bd2097
Merge #2757 (5ab04d7ee1) and #3106 sidebar-multiselect-click (639924e…
nledford Nov 6, 2026
381c9f2
LR-BEHAV-MULTISELECT: the menu, dragging and Delete key of several ch…
nledford Oct 26, 2026
f810140
LR-BEHAV-MULTISELECT: the Ukrainian Delete Albums sentence says тека,…
nledford Oct 26, 2026
2570503
LR-BEHAV-MULTISELECT: Spanish says the nested keywords and folders ar…
nledford Oct 26, 2026
f078518
LR-BEHAV-MULTISELECT: the Spanish keyword-delete count line also says…
nledford Oct 27, 2026
292045d
LR-BEHAV-MULTISELECT: a group of albums is dropped where an album cho…
nledford Oct 28, 2026
1dacef8
LR-BEHAV-MULTISELECT: a group of albums dropped beside a row places t…
nledford Oct 29, 2026
dd484c3
LR-BEHAV-MULTISELECT: a refused question about several rows closes it…
nledford Nov 4, 2026
6bd4074
LR-BEHAV-MULTISELECT: the French and Russian texts of the menus and t…
nledford Nov 4, 2026
ce9fb70
LR-BEHAV-MULTISELECT: the question for several rows is bound to the l…
nledford Nov 5, 2026
f485fcf
LR-BEHAV-MULTISELECT: deleting several shown albums in one call also …
nledford Nov 6, 2026
43bd687
docs: drop the stale 'later change' note for the sidebar clicks from …
nledford Nov 6, 2026
a3d0063
Merge branch 'sidebar-multiselect-click' into sidebar-multiselect-act…
nledford Nov 6, 2026
ddb7391
docs: say exporting several chosen rows is not an undo step in What's…
nledford Nov 6, 2026
524b569
docs: say when a view cannot be saved as a smart album in What's New
nledford Nov 6, 2026
a2beb07
Merge #1943 (abc98ec6705fce175b0e574590549fe68ea2ebfa) into #3107 (52…
nledford Nov 15, 2026
1a8c74a
LRC-LIB-LIBFOLDERS: Synchronize several folders at once, one after an…
nledford Oct 30, 2026
eb04b54
Synchronize several folders: the docs and a comment also say it reads…
nledford Oct 30, 2026
3bc747a
Synchronize several folders: ui.dialog.confirm's reply for the folder…
nledford Oct 30, 2026
0516e7d
Synchronize several folders: rustfmt of the restack's resolutions (im…
nledford Nov 15, 2026
f3d4275
Preview builds: a build asked to queue behind one with no row of its …
nledford Nov 15, 2026
c9e6583
Synchronize several folders: tests for the scan-failure, one-folder a…
nledford Nov 15, 2026
1d59136
Synchronize several folders: rustfmt of the new tests
nledford Nov 15, 2026
3aefe5b
Preview builds: a build with no row of its own is refused a place in …
nledford Nov 15, 2026
bc0e314
Synchronize several folders: the translation test no longer asks for …
nledford Nov 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 98 additions & 1 deletion crates/catalog/src/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//! photo has them, or given attributes ([`KeywordInfo`]: synonyms, export options, person). The
//! tree is the keyword list together with the keywords photos carry.

use std::collections::BTreeMap;
use std::collections::{BTreeMap, HashSet};

use serde::{Deserialize, Serialize};

Expand All @@ -35,6 +35,12 @@ pub fn is_under(k: &str, parent: &str) -> bool {
k == p || k.strip_prefix(&p).is_some_and(|rest| rest.starts_with(SEP))
}

/// The upper levels of a case folded keyword path, each as a prefix of it ending before a `|`
/// (`a|b|c` gives `a`, `a|b`), the way [`is_under`] sees them.
fn upper_levels(folded: &str) -> impl Iterator<Item = &str> {
folded.match_indices(SEP).map(|(i, _)| &folded[..i])
}

/// Replace the `from` prefix of `k` (which [`is_under`] `from`) with `to`. By levels, not bytes:
/// `from` may be written in another case, which can change a letter's length (ẞ / ß).
pub fn reparent(k: &str, from: &str, to: &str) -> String {
Expand Down Expand Up @@ -459,6 +465,97 @@ impl Catalog {
Ok(Op::Batch { ops })
}

/// [`Self::delete_keyword_ops`] for several keywords at once: one batch, so one undo step.
/// Unlike one keyword (which may be absent and then changes nothing), every keyword named must
/// exist, or the whole batch is refused.
pub fn delete_keywords_ops(&self, keywords: &[String]) -> Result<Op> {
let gone: Vec<String> = keywords.iter().map(|k| clean(k)).collect();
if gone.is_empty() || gone.iter().any(String::is_empty) {
return Err(CatalogError::Invalid("empty keyword".into()));
}
// case folded once here, and each candidate once below, not once per pair
let folded: Vec<String> = gone.iter().map(|g| g.to_lowercase()).collect();
let under = |k: &str, p: &str| k == p || k.strip_prefix(p).is_some_and(|rest| rest.starts_with(SEP));
let mut found = vec![false; folded.len()];
let listed = self.keyword_list.values().map(|l| &l.path);
for k in listed.chain(self.photos().filter(|p| p.in_library()).flat_map(|p| p.meta.keywords.iter())) {
let k = k.to_lowercase();
for (hit, p) in found.iter_mut().zip(&folded) {
*hit |= under(&k, p);
}
}
if let Some(i) = found.iter().position(|hit| !hit) {
return Err(CatalogError::Invalid(format!("no keyword “{}”", gone[i])));
}
let goes = |k: &str| {
let k = k.to_lowercase();
folded.iter().any(|p| under(&k, p))
};
let mut ops = self.keyword_ops(|kws| kws.iter().filter(|x| !goes(x)).cloned().collect());
ops.extend(self.list_ops(|list| list.retain(|_, l| !goes(&l.path))));
Ok(Op::Batch { ops })
}

/// Move several keywords (each with the keywords below it) inside `parent`, or to the top
/// level (`None`), as one batch. Each keeps its name. Of a keyword and one below it only the
/// upper one moves (the lower goes with it). Nothing merges here: a name that is taken where
/// they go ([`CatalogError::KeywordExists`]), or two of them with one name, refuses the whole
/// move. Returns the batch and each move as `(from, to)`.
pub fn move_keywords_ops(&self, keywords: &[String], parent: Option<&str>) -> Result<(Op, Vec<(String, String)>)> {
// paths are case folded once and kept in sets: a batch of thousands stays linear
let mut from: Vec<String> = Vec::new();
let mut seen: HashSet<String> = HashSet::new();
for k in keywords {
let path = self.keyword_path(k).ok_or_else(|| CatalogError::Invalid(format!("no keyword “{}”", clean(k))))?;
if seen.insert(path.to_lowercase()) {
from.push(path);
}
}
if from.is_empty() {
return Err(CatalogError::Invalid("no keyword to move".into()));
}
// the upper ones only: a keyword goes when one of its upper levels is named too
from.retain(|f| !upper_levels(&f.to_lowercase()).any(|up| seen.contains(up)));
let upper: HashSet<String> = from.iter().map(|f| f.to_lowercase()).collect();
let parent = parent.map(clean).filter(|p| !p.is_empty()).map(|p| self.keyword_path(&p).unwrap_or(p));
if let Some(p) = &parent {
let p = p.to_lowercase();
if upper.contains(&p) || upper_levels(&p).any(|up| upper.contains(up)) {
return Err(CatalogError::Invalid("can't move a keyword inside itself".into()));
}
}
let mut moves: Vec<(String, String)> = Vec::new();
let mut names: HashSet<String> = HashSet::new();
for f in &from {
let leaf = f.rsplit(SEP).next().unwrap_or(f);
let to = parent.as_deref().map_or_else(|| leaf.to_string(), |p| format!("{p}{SEP}{leaf}"));
if !names.insert(to.to_lowercase()) {
return Err(CatalogError::Invalid(format!("two of them are named “{leaf}”: move them one at a time")));
}
moves.push((f.clone(), to));
}
// one that is there already stays; the others must find their name free
moves.retain(|(f, t)| !same(f, t));
if let Some((_, taken)) = moves.iter().find(|(_, t)| self.has_keyword(t)) {
return Err(CatalogError::KeywordExists(taken.clone()));
}
// case folded once here and once per photo keyword, not once per pair
let folded_from: Vec<String> = moves.iter().map(|(f, _)| f.to_lowercase()).collect();
let moved = |k: &str| {
let k_folded = k.to_lowercase();
moves.iter().zip(&folded_from).find_map(|((f, t), f_folded)| {
let under = k_folded == *f_folded || k_folded.strip_prefix(f_folded.as_str()).is_some_and(|rest| rest.starts_with(SEP));
under.then(|| reparent(k, f, t))
})
};
let mut ops = self.keyword_ops(|kws| kws.iter().map(|k| moved(k).unwrap_or_else(|| k.clone())).collect());
// (the moves touch apart parts of the list: each one's listings are its own)
for (f, t) in &moves {
ops.extend(self.list_move_ops(std::slice::from_ref(f), t));
}
Ok((Op::Batch { ops }, moves))
}

/// Merge several keywords (with their children) into `into`.
pub fn merge_keywords_ops(&self, from: &[String], into: &str) -> Result<Op> {
let into = clean(into);
Expand Down
9 changes: 4 additions & 5 deletions crates/catalog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,9 @@ impl Catalog {
/// A loop through `filter`'s own album field (not its rules): smart album `owner` filtered to
/// itself, or to an album that leads back to it.
pub fn album_filter_problem(&self, filter: &Filter, owner: Option<AlbumId>) -> Option<rules::Problem> {
let (a, owner) = (filter.album?, owner?);
(a == owner || self.album_reaches(a, owner)).then(|| rules::Problem {
let owner = owner?;
let a = filter.albums_wanted().into_iter().find(|a| *a == owner || self.album_reaches(*a, owner))?;
Some(rules::Problem {
path: Vec::new(),
field: Some("album".into()),
issue: rules::Issue::AlbumLoop,
Expand Down Expand Up @@ -638,9 +639,7 @@ impl Catalog {
if rules.deleted {
return Err(CatalogError::Invalid("smart album rules can't select deleted photos".into()));
}
if let Some(a) = rules.album
&& self.albums.get(&a).is_some_and(Album::is_smart)
{
if rules.albums_wanted().iter().any(|a| self.albums.get(a).is_some_and(Album::is_smart)) {
return Err(CatalogError::Invalid("smart album rules can't reference another smart album".into()));
}
Ok(())
Expand Down
Loading