LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Merge branch 'main' into lightrroom-import-progress
Robert Woldberg8ee7519a5f4c
diff --cc crates/engine/src/import.rsindex 8a49ae8ba,20d1983e1..24b0cb3af--- a/crates/engine/src/import.rs+++ b/crates/engine/src/import.rs@@@ -864,13 -905,20 +919,22 @@@ impl ImportJob}}- // files a preceding scan already probed are not read again (a network share is slow to read)- let cached: Vec<Option<ProbeInfo>> = todo.iter().map(|f| self.cache.remove(f)).collect();+ // files a preceding scan already probed are not read again (a network share is slow to read),+ // as long as they are still there, as they were: a file gone or changed since is probed again+ let cached: Vec<Option<ProbeInfo>> = todo+ .iter()+ .map(|f| {+ // (the web's files are not std::fs files: kept as probed)+ self.cache+ .remove(f)+ .filter(|info| cfg!(target_arch = "wasm32") || std::fs::metadata(f).is_ok_and(|m| m.is_file() && m.len() == info.file_size))+ })+ .collect();let missing: Vec<String> = todo.iter().zip(&cached).filter(|(_, c)| c.is_none()).map(|(f, _)| f.clone()).collect();- let progress = ScanProgress::default();- let mut fresh = probe_all(self.probe.as_ref(), &missing, &progress).into_iter();+ // Reading the files is the slow part of adding them where they are: it is counted on its+ // own, and `cancel` stops it too (a large library takes long enough to want both).+ self.read_total.fetch_add(missing.len(), Relaxed);+ let mut fresh = probe_all(self.probe.as_ref(), &missing, &self.read_done, cancel).into_iter();let probed: Vec<Result<ProbeInfo, String>> =cached.into_iter().map(|c| c.map(Ok).unwrap_or_else(|| fresh.next().unwrap_or_else(|| Err("not probed".into())))).collect();crate::memory::release();diff --cc crates/engine/src/lightroom_job.rsindex 9a0658b48,33ed64a2d..ffd6fc183--- a/crates/engine/src/lightroom_job.rs+++ b/crates/engine/src/lightroom_job.rs@@@ -201,22 -141,23 +201,23 @@@ pub struct LightroomJobimpl LightroomJob {/// Snapshot session state only. This constructor performs no filesystem work.pub fn new(s: &mut crate::Session, path: PathBuf, update_existing: bool) -> crate::Result<Self> {- let opts = ImportOptions { mode: ImportMode::Add, ..ImportOptions::default() };+ // a photo deleted here stays deleted: the catalog's record is matched, not restored+ let opts = ImportOptions { mode: ImportMode::Add, on_deleted: crate::import::OnDeleted::Skip, ..ImportOptions::default() };let import = ImportJob::new(s, opts)?;let archive_dir = s.library.as_ref().filter(|library| library.on_disk).map(|library| library.dir.join("Interop"));- Ok(Self { path, update_existing, import, token: LightroomLibraryToken::capture(s), archive_dir })+ let progress = LightroomProgress {+ read_total: Arc::clone(&import.read_total),+ read_done: Arc::clone(&import.read_done),+ add_total: Arc::clone(&import.total),+ add_done: Arc::clone(&import.done),+ ..LightroomProgress::default()+ };+ Ok(Self { path, update_existing, import, token: LightroomLibraryToken::capture(s), archive_dir, progress })}- pub fn total(&self) -> usize {- self.import.total.load(Ordering::Relaxed)- }-- pub fn done(&self) -> usize {- self.import.done.load(Ordering::Relaxed)- }-- pub fn progress(&self) -> (usize, usize) {- (self.done(), self.total())+ /// The job's progress, to watch from another thread while [`LightroomJob::prepare`] runs.+ pub fn progress(&self) -> LightroomProgress {+ self.progress.clone()}pub fn token(&self) -> &LightroomLibraryToken {diff --cc crates/ui-egui/locales/de.jsonindex c24b59cc0,10cc7e0ed..73bd50a18--- a/crates/ui-egui/locales/de.json+++ b/crates/ui-egui/locales/de.json@@@ -1800,6 -1813,6 +1813,8 @@@"Install the SAM 3 Model": "SAM-3-Modell installieren","This build can't download the model yet. To install it by hand, put model.safetensors, vocab.json and merges.txt from Meta's facebook/sam3 in the folder above: Object and Describe work as soon as they are there.": "Diese Version kann das Modell noch nicht herunterladen. Zum Installieren von Hand lege model.safetensors, vocab.json und merges.txt aus Metas facebook/sam3 in den obigen Ordner: Objekt und Beschreiben funktionieren, sobald sie dort liegen.","Open Log Folder": "Protokollordner öffnen",++ "Reading photos…": "Fotos werden gelesen…",++ "Adding photos…": "Fotos werden hinzugefügt…","Back to this person": "Back to this person","AI Denoise": "AI Denoise","AI Denoise Model": "AI Denoise Model",diff --cc crates/ui-egui/locales/es.jsonindex 387ac9717,ff672e88d..a1bacb21c--- a/crates/ui-egui/locales/es.json+++ b/crates/ui-egui/locales/es.json@@@ -1645,6 -1658,6 +1658,8 @@@"Captured until": "Capturadas hasta","Only": "Solo","Open Log Folder": "Abrir carpeta de registros",++ "Reading photos…": "Leyendo fotos…",++ "Adding photos…": "Añadiendo fotos…","Back to this person": "Back to this person","AI Denoise": "AI Denoise","AI Denoise Model": "AI Denoise Model",diff --cc crates/ui-egui/locales/ja.jsonindex b05baac24,9b9ae4c35..682fc2320--- a/crates/ui-egui/locales/ja.json+++ b/crates/ui-egui/locales/ja.json@@@ -1645,6 -1658,6 +1658,8 @@@"Install the SAM 3 Model": "SAM 3モデルのインストール","This build can't download the model yet. To install it by hand, put model.safetensors, vocab.json and merges.txt from Meta's facebook/sam3 in the folder above: Object and Describe work as soon as they are there.": "このビルドではまだモデルをダウンロードできません。手動でインストールするには、Meta の facebook/sam3 の model.safetensors、vocab.json、merges.txt を上のフォルダに置いてください。置いた時点で「オブジェクト」と「説明で選択」が使えるようになります。","Open Log Folder": "ログフォルダーを開く",++ "Reading photos…": "写真を確認中…",++ "Adding photos…": "写真を追加中…","Back to this person": "Back to this person","AI Denoise": "AI Denoise","AI Denoise Model": "AI Denoise Model",diff --cc crates/ui-egui/locales/pt-br.jsonindex ab7f39734,9c16f1110..7c193348f--- a/crates/ui-egui/locales/pt-br.json+++ b/crates/ui-egui/locales/pt-br.json@@@ -942,6 -949,6 +949,8 @@@"Open Library": "Abrir biblioteca","Open Library…": "Abrir biblioteca…","Open Log Folder": "Abrir pasta de logs",++ "Reading photos…": "Lendo fotos…",++ "Adding photos…": "Adicionando fotos…","Open in": "Abrir em","Open in Detail": "Abrir em Detalhe","Open the place in OpenStreetMap": "Abrir o local no OpenStreetMap",diff --cc crates/ui-egui/locales/ru.jsonindex 517e2613f,a84297a05..9adde5d2a--- a/crates/ui-egui/locales/ru.json+++ b/crates/ui-egui/locales/ru.json@@@ -777,6 -784,6 +784,8 @@@"Open Library": "Открыть библиотеку","Open Library…": "Открыть библиотеку…","Open Log Folder": "Открыть папку журналов",++ "Reading photos…": "Чтение фото…",++ "Adding photos…": "Добавление фото…","Open in": "Открыть в","Open in Detail": "Открыть в режиме «Детализация»","Open the place in OpenStreetMap": "Открыть место в OpenStreetMap",diff --cc crates/ui-egui/locales/zh-hans.jsonindex 46728b628,2b48b8e9b..0de828944--- a/crates/ui-egui/locales/zh-hans.json+++ b/crates/ui-egui/locales/zh-hans.json@@@ -1645,94 -1658,336 +1658,338 @@@"Install the SAM 3 Model": "安装 SAM 3 模型","This build can't download the model yet. To install it by hand, put model.safetensors, vocab.json and merges.txt from Meta's facebook/sam3 in the folder above: Object and Describe work as soon as they are there.": "此版本尚无法下载模型。如需手动安装,请将 Meta 的 facebook/sam3 中的 model.safetensors、vocab.json 和 merges.txt 放入上方的文件夹:放入后即可使用“对象”和“描述”。","Open Log Folder": "打开日志文件夹",- "Back to this person": "Back to this person",- "AI Denoise": "AI Denoise",- "AI Denoise Model": "AI Denoise Model",- "AI Denoise is off: press Use on a model.": "AI Denoise is off: press Use on a model.",- "AI Denoise needs a model. Install one in Settings.": "AI Denoise needs a model. Install one in Settings.",- "Accept & Download": "Accept & Download",- "Already installed. Remove it before installing a replacement.": "Already installed. Remove it before installing a replacement.",- "Automatic uses the graphics card where it is faster than the processor: both are timed on this computer the first time a photo is made.": "Automatic uses the graphics card where it is faster than the processor: both are timed on this computer the first time a photo is made.",- "Cache": "Cache",- "Checking and installing the model…": "Checking and installing the model…",- "Checking…": "Checking…",- "Clear cache": "Clear cache",- "Denoise Models": "Denoise Models",- "Denoise Settings": "Denoise Settings",- "Denoise all photos with an Amount": "Denoise all photos with an Amount",- "Downloaded and checked. Installing…": "Downloaded and checked. Installing…",- "Failed its last test": "Failed its last test",- "Graphics card": "Graphics card",- "I have read these terms and accept them for my own use": "I have read these terms and accept them for my own use",- "Inspect Denoise Model": "Inspect Denoise Model",- "Install Denoise Model": "Install Denoise Model",- "Install from file…": "Install from file…",- "Install your own ONNX model with denoise-model.json beside it. This build offers no model downloads.": "Install your own ONNX model with denoise-model.json beside it. This build offers no model downloads.",- "Its denoised picture is not made yet, and pictures are not made on their own (Settings, AI Denoise).": "Its denoised picture is not made yet, and pictures are not made on their own (Settings, AI Denoise).",- "LightCraft does not know this model, so it assumed:": "LightCraft does not know this model, so it assumed:",- "Limit": "Limit",- "Make it now": "Make it now",- "Make the denoised picture of the photos I am looking at": "Make the denoised picture of the photos I am looking at",- "Next up for AI Denoise…": "Next up for AI Denoise…",- "Nothing is fetched until you accept. The model is kept on this computer only; LightCraft never uploads or shares it.": "Nothing is fetched until you accept. The model is kept on this computer only; LightCraft never uploads or shares it.",- "Only photos whose AI Denoise amount is above 0 are made. Exports always make theirs if it is missing.": "Only photos whose AI Denoise amount is above 0 are made. Exports always make theirs if it is missing.",- "Open page": "Open page",- "Open the model's page": "Open the model's page",- "Opens the model's own page in your browser, to read about it or get the file yourself.": "Opens the model's own page in your browser, to read about it or get the file yourself.",- "Processor": "Processor",- "Set up AI Denoise…": "Set up AI Denoise…",- "Speed": "Speed",- "Starting…": "Starting…",- "Tested and works on this computer": "Tested and works on this computer",- "The denoise model is installed and in use: the AI Denoise Amount slider under Detail now works": "The denoise model is installed and in use: the AI Denoise Amount slider under Detail now works",- "The graphics card is set up when the next photo is made.": "The graphics card is set up when the next photo is made.",- "The model is kept on this computer only. LightCraft never uploads or shares it.": "The model is kept on this computer only. LightCraft never uploads or shares it.",- "The processor does the work.": "The processor does the work.",- "There is no model file to install": "There is no model file to install",- "This build cannot run denoise models.": "This build cannot run denoise models.",- "This build has nowhere to keep denoise models, so AI Denoise is not available. (The desktop app has.)": "This build has nowhere to keep denoise models, so AI Denoise is not available. (The desktop app has.)",- "This file cannot be used yet": "This file cannot be used yet",- "Tick the box to accept the model's terms first": "Tick the box to accept the model's terms first",- "Try again": "Try again",- "Try the graphics card again": "Try the graphics card again",- "Turn off": "Turn off",- "Unknown licence": "Unknown licence",- "Use": "Use",- "Waiting to start…": "Waiting to start…",- "Works on raw files from cameras with a standard (Bayer) sensor. Other files keep their normal noise reduction.": "Works on raw files from cameras with a standard (Bayer) sensor. Other files keep their normal noise reduction.",- "cached picture": "cached picture",- "cached pictures": "cached pictures",- "commercial use allowed": "commercial use allowed",++ "Reading photos…": "正在读取照片…",++ "Adding photos…": "正在添加照片…",+ "Back to this person": "返回此人",+ "AI Denoise": "AI 降噪",+ "AI Denoise Model": "AI 降噪模型",+ "AI Denoise is off: press Use on a model.": "AI 降噪已关闭:请在某个模型上点击“使用”。",+ "AI Denoise needs a model. Install one in Settings.": "AI 降噪需要模型。请在设置中安装一个。",+ "Accept & Download": "接受并下载",+ "Already installed. Remove it before installing a replacement.": "已安装。安装替代模型前请先将其移除。",+ "Automatic uses the graphics card where it is faster than the processor: both are timed on this computer the first time a photo is made.": "自动模式会在显卡快于处理器时使用显卡:两者都会在首次生成照片时于本机计时比较。",+ "Cache": "缓存",+ "Checking and installing the model…": "正在检查并安装模型…",+ "Checking…": "正在检查…",+ "Clear cache": "清除缓存",+ "Denoise Models": "降噪模型",+ "Denoise Settings": "降噪设置",+ "Denoise all photos with an Amount": "对所有设置了数量的照片进行降噪",+ "Downloaded and checked. Installing…": "已下载并校验完成。正在安装…",+ "Failed its last test": "上次检测未通过",+ "Graphics card": "显卡",+ "I have read these terms and accept them for my own use": "我已阅读这些条款,并为个人使用表示接受",+ "Inspect Denoise Model": "查看降噪模型",+ "Install Denoise Model": "安装降噪模型",+ "Install from file…": "从文件安装…",+ "Install your own ONNX model with denoise-model.json beside it. This build offers no model downloads.": "请自行安装 ONNX 模型,并在其旁边放置 denoise-model.json。此版本不提供模型下载。",+ "Its denoised picture is not made yet, and pictures are not made on their own (Settings, AI Denoise).": "该照片的降噪结果尚未生成,而且不会自动生成(设置、AI 降噪)。",+ "LightCraft does not know this model, so it assumed:": "LightCraft 不认识此模型,因此按以下假设处理:",+ "Limit": "上限",+ "Make it now": "立即生成",+ "Make the denoised picture of the photos I am looking at": "为我正在查看的照片生成降噪结果",+ "Next up for AI Denoise…": "接下来的 AI 降噪任务…",+ "Nothing is fetched until you accept. The model is kept on this computer only; LightCraft never uploads or shares it.": "在你接受之前不会下载任何内容。模型仅保存在本机;LightCraft 绝不会上传或分享它。",+ "Only photos whose AI Denoise amount is above 0 are made. Exports always make theirs if it is missing.": "只对 AI 降噪数量大于 0 的照片生成结果。导出时若缺少结果则会先生成。",+ "Open page": "打开页面",+ "Open the model's page": "打开该模型的页面",+ "Opens the model's own page in your browser, to read about it or get the file yourself.": "在浏览器中打开该模型的主页,以便查阅说明或自行获取文件。",+ "Processor": "处理器",+ "Set up AI Denoise…": "设置 AI 降噪…",+ "Speed": "速度",+ "Starting…": "正在启动…",+ "Tested and works on this computer": "已在本机测试通过并可正常使用",+ "The denoise model is installed and in use: the AI Denoise Amount slider under Detail now works": "降噪模型已安装并正在使用:细节面板中的 AI 降噪数量滑块现已可用",+ "The graphics card is set up when the next photo is made.": "将在生成下一张照片时初始化显卡。",+ "The model is kept on this computer only. LightCraft never uploads or shares it.": "模型仅保存在本机。LightCraft 绝不会上传或分享它。",+ "The processor does the work.": "由处理器完成运算。",+ "There is no model file to install": "没有可安装的模型文件",+ "This build cannot run denoise models.": "此版本无法运行降噪模型。",+ "This build has nowhere to keep denoise models, so AI Denoise is not available. (The desktop app has.)": "此版本没有存放降噪模型的位置,因此无法使用 AI 降噪。(桌面版可以。)",+ "This file cannot be used yet": "此文件暂时无法使用",+ "Tick the box to accept the model's terms first": "请先勾选以接受该模型的条款",+ "Try again": "重试",+ "Try the graphics card again": "重新尝试使用显卡",+ "Turn off": "关闭",+ "Unknown licence": "许可证未知",+ "Use": "使用",+ "Waiting to start…": "等待启动…",+ "Works on raw files from cameras with a standard (Bayer) sensor. Other files keep their normal noise reduction.": "适用于采用标准(拜耳)传感器的相机 RAW 文件。其他文件仍使用常规降噪。",+ "cached picture": "张已缓存的照片",+ "cached pictures": "张已缓存的照片",+ "commercial use allowed": "允许商用","denoiseModel.accept": "denoiseModel.accept",- "in use": "in use",- "installed": "installed",- "makes AI Denoise available": "makes AI Denoise available",- "non-commercial use only": "non-commercial use only",- "photo has its denoised picture.": "photo has its denoised picture.",- "photo waiting": "photo waiting",- "photos have their denoised picture.": "photos have their denoised picture.",- "photos waiting": "photos waiting",- "starts using it for AI Denoise": "starts using it for AI Denoise",- "terms unclear": "terms unclear",- "the graphics card": "the graphics card",- "the graphics card is not used": "the graphics card is not used",- "Cancel Denoise": "Cancel Denoise",- "Cancel Denoise Model Download": "Cancel Denoise Model Download",- "Choose Denoise Model": "Choose Denoise Model",- "Clear Denoise Cache": "Clear Denoise Cache",- "Denoise Model Downloads": "Denoise Model Downloads",- "Denoise Photos": "Denoise Photos",- "Denoise Pump": "Denoise Pump",- "Denoise Status": "Denoise Status",- "Download Denoise Model": "Download Denoise Model",- "Remove Denoise Model": "Remove Denoise Model",- "Test Denoise Model": "Test Denoise Model",- "AI Denoise is enabled on the requesting photo": "AI Denoise is enabled on the requesting photo",- "After installation, AI Denoise will turn on for the requesting photo.": "After installation, AI Denoise will turn on for the requesting photo.",- "Cancel pending action": "Cancel pending action",- "Install a denoise model to enable AI Denoise on this photo": "Install a denoise model to enable AI Denoise on this photo",- "Pending photo action cancelled": "Pending photo action cancelled",- "Pending photo action cancelled because its library or photo changed": "Pending photo action cancelled because its library or photo changed",- "ONNX model": "ONNX model",- "commercial use subject to GPL conditions": "commercial use subject to GPL conditions"+ "in use": "正在使用",+ "installed": "已安装",+ "makes AI Denoise available": "以启用 AI 降噪",+ "non-commercial use only": "仅限非商用",+ "photo has its denoised picture.": "张照片已有降噪结果。",+ "photo waiting": "张照片等待中",+ "photos have their denoised picture.": "张照片已有降噪结果。",+ "photos waiting": "张照片等待中",+ "starts using it for AI Denoise": "开始用它进行 AI 降噪",+ "terms unclear": "条款不明确",+ "the graphics card": "显卡",+ "the graphics card is not used": "未使用显卡",+ "Cancel Denoise": "取消降噪",+ "Cancel Denoise Model Download": "取消降噪模型下载",+ "Choose Denoise Model": "选择降噪模型",+ "Clear Denoise Cache": "清除降噪缓存",+ "Denoise Model Downloads": "降噪模型下载",+ "Denoise Photos": "照片降噪",+ "Denoise Pump": "降噪队列",+ "Denoise Status": "降噪状态",+ "Download Denoise Model": "下载降噪模型",+ "Remove Denoise Model": "移除降噪模型",+ "Test Denoise Model": "测试降噪模型",+ "AI Denoise is enabled on the requesting photo": "已在发起请求的照片上启用 AI 降噪",+ "After installation, AI Denoise will turn on for the requesting photo.": "安装完成后,将为发起请求的照片开启 AI 降噪。",+ "Cancel pending action": "取消待处理操作",+ "Install a denoise model to enable AI Denoise on this photo": "安装降噪模型后即可在此照片上启用 AI 降噪",+ "Pending photo action cancelled": "已取消待处理的照片操作",+ "Pending photo action cancelled because its library or photo changed": "待处理的照片操作已取消,因为其所属图库或照片发生了变化",+ "ONNX model": "ONNX 模型",+ "commercial use subject to GPL conditions": "商用须遵循 GPL 条款",+ "Decrease Rating": "降低星级",+ "Increase Rating": "提高星级",+ "Click to type a value": "单击以输入数值",+ "Angle": "角度",+ "Video": "视频",+ "Copyrighted": "受版权保护",+ "Public Domain": "公共领域",+ "Unknown": "未知",+ "Landscape (wide)": "横向",+ "Portrait (tall)": "纵向",+ "Square": "正方形",+ "In Color": "彩色",+ "No Label": "无标签",+ "Choose an album…": "选择相册…",+ "No albums yet": "还没有相册",+ "Fix the marked rules to save this album.": "请修正标记的规则以保存此相册。",+ "Some rules need fixing (Edit Smart Album…):": "有些规则需要修正(编辑智能相册…):",+ "isn't a field rules know": "不是已知的字段",+ "can't be tested that way": "不能这样判断",+ "is yes or no": "只能是“是”或“否”",+ "needs a number": "需要一个数字",+ "needs a time like 1/250 or 2": "需要类似 1/250 或 2 的快门速度",+ "needs a date like 2026, 2026-08 or 2026-08-14": "需要类似 2026、2026-08 或 2026-08-14 的日期",+ "has the first date after the second": "第一个日期晚于第二个",+ "needs two values": "需要两个值",+ "needs a number more than 0": "需要大于 0 的数字",+ "needs hours, days, weeks, months or years": "需要小时、天、周、月或年",+ "isn't one of the choices": "不是可选项之一",+ "needs something to look for (or use “is empty”)": "需要要查找的内容(或使用“为空”)",+ "needs something to look for (or use “isn't empty”)": "需要要查找的内容(或使用“不为空”)",+ "needs text": "需要文本",+ "can't match any rating from 0 to 5": "不匹配 0 到 5 的任何星级",+ "needs an album": "需要选择相册",+ "names an album that no longer exists": "指定的相册已不存在",+ "can't test a folder; choose an album in it": "无法判断文件夹;请选择其中的相册",+ "This group is empty: add a rule or remove it.": "此组为空:请添加规则或将其删除。",+ "needs something to look for (or use “are empty”)": "需要要查找的内容(或使用“为空”)",+ "needs something to look for (or use “aren't empty”)": "需要要查找的内容(或使用“不为空”)",+ "Mo": "一",+ "Tu": "二",+ "We": "三",+ "Th": "四",+ "Fr": "五",+ "Sa": "六",+ "Su": "日",+ "Pick a date": "选择日期",+ "would make this album include itself through other smart albums": "会通过其他智能相册让此相册包含自身",+ "Search albums": "搜索相册",+ "No albums match": "没有匹配的相册",+ "This is the album you're editing": "这是正在编辑的相册",+ "It tests this album, so testing it back would loop": "它引用了此相册,反过来引用会形成循环",+ "Copy Name": "副本名称",+ "In a Stack": "在堆叠中",+ "File Extension": "文件扩展名",+ "Video Duration": "视频时长",+ "Keyword Count": "关键字数量",+ "People Count": "人物数量",+ "Shutter Speed": "快门速度",+ "Cropped": "已裁剪",+ "Keywords & People": "关键字与人物",+ "Description": "描述",+ "Camera Info": "相机信息",+ "Develop": "编辑",+ "Keyword List": "关键字列表",+ "Filter Keywords": "过滤关键字",+ "No keywords yet": "还没有关键字",+ "No keywords match": "没有匹配的关键字",+ "Keyword Name": "关键字名称",+ "Synonyms": "同义词",+ "Separated by commas": "用逗号分隔",+ "Keyword Tag Options": "关键字标记选项",+ "Include on Export": "导出时包含",+ "Export Containing Keywords": "导出上级关键字",+ "Export Synonyms": "导出同义词",+ "Create Keyword Tag": "创建关键字标记",+ "Edit Keyword Tag": "编辑关键字标记",+ "Create": "创建",+ "No photo has it; the keywords below it go too.": "没有照片使用它;其下的关键字也会一并删除。",+ "Edit Keyword Tag…": "编辑关键字标记…",+ "Put New Keywords Inside This Keyword": "将新关键字放入此关键字中",+ "Purge Unused Keywords": "清除未使用的关键字",+ "Delete Keyword…": "删除关键字…",+ "Drop here for the top level": "拖放到此处以移至顶层",+ "Their photos and the keywords below them come together under one keyword.": "它们的照片和下级关键字将合并到同一个关键字下。",+ "Select photos to give them keywords.": "选择照片以为其添加关键字。",+ "Add to All Selected Photos": "添加到所有所选照片",+ "Will Export": "将导出",+ "No keywords are exported": "没有要导出的关键字",+ "& Containing": "及上级",+ "Edit Set…": "编辑关键字集…",+ "Edit Keyword Set": "编辑关键字集",+ "Keywords (⌥1–⌥9)": "关键字 (⌥1–⌥9)",+ "A keyword set needs a name": "关键字集需要名称",+ "Save as a new set": "另存为新关键字集",+ "Recent Keywords is built in: choose another name": "“最近使用的关键字”为内置集:请另选名称",+ "Import Keywords…": "导入关键字…",+ "Export Keywords…": "导出关键字…",+ "Import Keywords": "导入关键字",+ "Export Keywords": "导出关键字",+ "Keyword Lists": "关键字列表",+ "Synchronize Folder…": "同步文件夹…",+ "Synchronize Folder": "同步文件夹",+ "Synchronize": "同步",+ "Scanning…": "正在扫描…",+ "Find photos added to or missing from this folder on disk, and XMP sidecars changed by other apps": "查找磁盘上此文件夹中新增或缺失的照片,以及被其他应用更改的 XMP 附属文件",+ "Bring the library up to date with this folder and the folders inside it:": "让图库与此文件夹及其中的文件夹保持一致:",+ "Import new photos": "导入新照片",+ "Remove missing photos from the library": "从图库中移除缺失的照片",+ "Read metadata updates from XMP sidecars": "从 XMP 附属文件读取元数据更新",+ "The library is up to date with this folder.": "图库与此文件夹一致。",+ "Missing photos move to Recently Deleted and can be restored; no file on disk is touched.": "缺失的照片会移到“最近删除”,可以恢复;磁盘上的文件不会被改动。",+ "Reading a sidecar replaces the photo's rating, labels, metadata and edits with what it says.": "读取附属文件会用其内容替换照片的评级、标签、元数据和编辑。",+ "Skipped: files already in the library elsewhere": "已跳过:已在图库其他位置的文件",+ "Skipped: files that can't be read": "已跳过:无法读取的文件",+ "This folder isn't there: it was moved or renamed, or its disk isn't connected.": "此文件夹不存在:它已被移动或重命名,或其磁盘未连接。",+ "Relink photos whose file was renamed or moved": "重新链接文件被重命名或移动的照片",+ "A folder is already being synchronized": "已有文件夹正在同步",+ "Synchronizing…": "正在同步…",+ "Relinked": "已重新链接",+ "Removed": "已移除",+ "Metadata read": "已读取元数据",+ "Failed": "失败",+ "Stopped": "已停止",+ "Stopped by an error (see the log)": "因错误而停止(见日志)",+ "Not saved": "未保存",+ "A folder is being synchronized": "正在同步文件夹",+ "Wait for the import to finish": "请等待导入完成",+ "Appearance": "外观",+ "Appearance Mode": "外观模式",+ "Sync with System": "与系统同步",+ "Light Mode": "浅色模式",+ "Dark Mode": "深色模式",+ "Next Appearance Mode": "下一个外观模式",+ "Light Theme": "浅色主题",+ "Dark Theme": "深色主题",+ "In Use": "使用中",+ "Charcoal": "炭灰",+ "Midnight": "午夜",+ "Silver": "银色",+ "Paper": "纸白",+ "Show less": "收起",+ "Quit while tasks are running?": "要在任务运行时退出吗?",+ "Exporting contact sheet": "正在导出联系表",+ "Reading folder": "正在读取文件夹",+ "Scanning folder": "正在扫描文件夹",+ "Building previews": "正在构建预览",+ "Building smart previews": "正在构建智能预览",+ "Discarding smart previews": "正在丢弃智能预览",+ "Importing Lightroom catalog": "正在导入 Lightroom 目录",+ "Reading Lightroom catalog": "正在读取 Lightroom 目录",+ "Merging": "正在合并",+ "Downloading model": "正在下载模型",+ "Finding faces": "正在查找人脸",+ "Synchronizing folder": "正在同步文件夹",+ "Looking for changes": "正在查找更改",+ "This is a Lightroom catalog, not a LightCraft library. Import it into a LightCraft library instead?": "这是 Lightroom 目录,不是 LightCraft 图库。要改为将其导入 LightCraft 图库吗?",+ "The import reads the catalog without changing it and adds its photos, edits, keywords and collections to the library open now.": "导入只读取目录、不做任何更改,并将其中的照片、编辑、关键字和收藏夹添加到当前打开的图库。",+ "Albums hold library photos: Add to My Photos first": "相册只能收录图库中的照片:请先添加到我的照片",+ "Add to My Photos First": "先添加到我的照片",+ "Fill Location from GPS": "根据 GPS 填写位置",+ "Download Place Names (GeoNames)": "下载地名数据 (GeoNames)",+ "Place Names Status": "地名数据状态",+ "Fill Location": "填写位置",+ "Fill empty City, State and Country from GPS (offline GeoNames place names)": "根据 GPS 填写空白的城市、省/州和国家(GeoNames 地名,离线)",+ "Looking up places": "正在查找地点",+ "Downloading place names": "正在下载地名数据",+ "Place names downloaded": "地名数据已下载",+ "Place names download cancelled": "已取消下载地名数据",+ "Other…": "其他…",+ "Intent:": "方法:",+ "Perceptual": "可感知",+ "Relative": "相对",+ "Simulate Paper & Ink": "模拟纸张和油墨",+ "Content-Aware": "内容识别",+ "Sidebar Sections": "边栏分区",+ "Reset Sidebar Sections": "重置边栏分区",+ "Hide This Section": "隐藏此分区",+ "No folders to browse": "没有可浏览的文件夹",+ "No photos yet": "还没有照片",+ "No imported folders yet": "还没有导入的文件夹",+ "Show Sidebar Section": "显示边栏分区",+ "Move Sidebar Section": "移动边栏分区",+ "New Library…": "新建图库…",+ "Open Recent Library": "打开最近的图库",+ "Recent Libraries": "最近的图库",+ "Clear Recent Libraries": "清除最近的图库",+ "No Recent Libraries": "没有最近的图库",+ "New Library: Choose Where to Put It": "新建图库:选择存放位置",+ "New Library": "新建图库",+ "Library name": "图库名称",+ "New Folder on Disk": "在磁盘上新建文件夹",+ "New Folder on Disk…": "在磁盘上新建文件夹…",+ "Move to Folder": "移动到文件夹",+ "Move to Folder…": "移动到文件夹…",+ "Move Selected Photos Here": "将所选照片移到此处",+ "Moves the files and their XMP sidecars into this folder; never overwrites": "将文件及其 XMP 附属文件移到此文件夹;绝不覆盖",+ "Appearance Settings…": "外观设置…",+ "Add to favorites": "添加到收藏",+ "Remove from favorites": "从收藏中移除",+ "Add Face Model…": "添加人脸模型…",+ "Cancel Face Model Download": "取消人脸模型下载",+ "Cancel Pending Photo Action": "取消待处理的照片操作",+ "Choose Face Recognition Model": "选择人脸识别模型",+ "Choose a model below (Use) to start.": "请在下方选择模型(点击“使用”)以开始。",+ "Detect Faces": "检测人脸",+ "Download Face Model": "下载人脸模型",+ "Drag Crop Handle": "拖动裁切手柄",+ "Evaluate Face Recognition": "评估人脸识别",+ "Face Model Downloads": "人脸模型下载",+ "Face Models": "人脸模型",+ "Face Recognition On/Off": "人脸识别开关",+ "Face detector": "人脸检测器",+ "Face recognition": "人脸识别",+ "Faces": "人脸",+ "Faces of a Person": "某个人的人脸",+ "Go back to listing them by name": "返回按名称列出",+ "Index Faces": "索引人脸",+ "Index Faces in the Background": "在后台索引人脸",+ "Inspect Face Model File": "查看人脸模型文件",+ "Install Face Model": "安装人脸模型",+ "Library Folders": "图库文件夹",+ "Name Face": "命名人脸",+ "Name Faces": "命名人脸",+ "Recognise faces (experimental)": "识别面部(实验功能)",+ "Recognition models": "识别模型",+ "Remove Face Model": "移除人脸模型",+ "Reorder Album": "重排相册",+ "Show Person": "显示人物",+ "Sort Albums A–Z": "相册按 A–Z 排序",+ "Sort Albums by Name": "相册按名称排序",+ "Sort Contents A–Z": "内容按 A–Z 排序",+ "Suggest Names for Faces": "为人脸建议名称",+ "Test Face Model": "测试人脸模型",+ "Unnamed Faces": "未命名人脸",+ "save goes through.": "才能完成保存。",+ "smart album value|No": "智能相册取值|否",+ "smart album value|Yes": "智能相册取值|是",+ "Add to Apple Photos": "添加到 Apple 照片",+ "Adding to Apple Photos…": "正在添加到 Apple 照片…",+ "not added to Apple Photos (cancelled)": "未添加到 Apple 照片(已取消)",+ "The first time, macOS asks whether LightCraft may control Photos.": "首次使用时,macOS 会询问是否允许 LightCraft 控制“照片”。",+ "Adding to Apple Photos": "正在添加到 Apple 照片"}diff --cc crates/ui-egui/locales/zh-hant.jsonindex 083c98c2e,0e81c6e92..6e6b94500--- a/crates/ui-egui/locales/zh-hant.json+++ b/crates/ui-egui/locales/zh-hant.json@@@ -1645,6 -1658,6 +1658,8 @@@"Install the SAM 3 Model": "安裝 SAM 3 模型","This build can't download the model yet. To install it by hand, put model.safetensors, vocab.json and merges.txt from Meta's facebook/sam3 in the folder above: Object and Describe work as soon as they are there.": "此版本尚無法下載模型。如需手動安裝,請將 Meta 的 facebook/sam3 中的 model.safetensors、vocab.json 和 merges.txt 放入上方的資料夾:放入後即可使用「物件」與「描述」。","Open Log Folder": "開啟記錄資料夾",++ "Reading photos…": "正在讀取照片…",++ "Adding photos…": "正在新增照片…","Back to this person": "Back to this person","AI Denoise": "AI Denoise","AI Denoise Model": "AI Denoise Model",diff --cc crates/ui-egui/src/lightroom_import.rsindex 774e92d8b,815e98576..ef6b49432--- a/crates/ui-egui/src/lightroom_import.rs+++ b/crates/ui-egui/src/lightroom_import.rs@@@ -5,11 -5,10 +5,11 @@@//! data only on the owner thread, then finishes the archive index on a worker.use std::path::PathBuf;-use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};+use std::sync::atomic::{AtomicBool, Ordering};use std::sync::{Arc, mpsc};- use egui::Align2;+ use lightcraft_engine::activity::{Cancel, TaskGuard};+use lightcraft_engine::lightroom_job::{LightroomProgress, LightroomStep};use serde_json::{Value, json};use crate::LightcraftApp;@@@ -47,6 -46,49 +46,53 @@@ pub struct LightroomTask}impl LightroomTask {+ #[cfg(not(target_arch = "wasm32"))]+ fn new(+ s: &lightcraft_engine::Session,+ kind: Kind,+ path: PathBuf,+ cancel: Arc<AtomicBool>,- total: Arc<AtomicUsize>,- done: Arc<AtomicUsize>,++ progress: LightroomProgress,+ rx: mpsc::Receiver<Message>,+ ) -> Self {+ let label = match kind {+ Kind::Inspect => "Reading Lightroom catalog",+ Kind::Import => "Importing Lightroom catalog",+ };+ let guard = s.activity.start("lightroom", label, Cancel::Flag(cancel.clone()));- let task = Self { kind, path, cancel, total, done, rx, phase: Phase::Reading, cancelled: false, guard };++ let task = Self { kind, path, cancel, progress, rx, phase: Phase::Reading, cancelled: false, guard };+ task.refresh();+ task+ }++ /// Move to `phase`; only reading the catalog can stop, adding the photos runs to the end.+ fn enter(&mut self, phase: Phase) {+ self.phase = phase;+ self.guard.set_cancellable(phase == Phase::Reading);+ self.refresh();+ }+- /// Bring the activity row up to date: the count while reading, then what is being done.++ /// Bring the activity row up to date: while reading, the step under way and its own count++ /// (reading the photos takes nearly all of an import, so it is counted, not waited out);++ /// then what is being done.+ fn refresh(&self) {- let detail = match (self.phase, self.kind) {- (Phase::Reading, Kind::Inspect) => "",- (Phase::Reading, Kind::Import) => crate::i18n::tr("Reading Lightroom catalog…"),- (Phase::Committing, _) => crate::i18n::tr("Adding Lightroom photos…"),- (Phase::Finalizing, _) => crate::i18n::tr("Saving Lightroom import index…"),++ let (step, done, total) = self.progress.step();++ let detail = match (self.phase, self.kind, step) {++ (Phase::Reading, Kind::Inspect, _) => "",++ (Phase::Reading, Kind::Import, LightroomStep::Catalog) => crate::i18n::tr("Reading Lightroom catalog…"),++ (Phase::Reading, Kind::Import, LightroomStep::ReadPhotos) => crate::i18n::tr("Reading photos…"),++ (Phase::Reading, Kind::Import, LightroomStep::AddPhotos) => crate::i18n::tr("Adding photos…"),++ (Phase::Committing, ..) => crate::i18n::tr("Adding Lightroom photos…"),++ (Phase::Finalizing, ..) => crate::i18n::tr("Saving Lightroom import index…"),+ };+ if self.phase == Phase::Reading {- self.guard.progress(self.done.load(Ordering::Relaxed) as u64, self.total.load(Ordering::Relaxed) as u64);++ self.guard.progress(done as u64, total as u64);+ } else {+ self.guard.progress(0, 0);+ }+ self.guard.detail(detail);+ }+#[cfg(not(target_arch = "wasm32"))]fn status(&self) -> Value {let kind = match self.kind {@@@ -238,11 -278,12 +289,11 @@@ fn terminal(app: &mut LightcraftApp, ctfn start_inspect(app: &mut LightcraftApp, path: PathBuf, ctx: &egui::Context) -> Result<Value, String> {busy(app)?;let cancel = Arc::new(AtomicBool::new(false));- let total = Arc::new(AtomicUsize::new(0));- let done = Arc::new(AtomicUsize::new(0));+ let progress = LightroomProgress::default();let (tx, rx) = mpsc::channel();- spawn_inspect(path.clone(), cancel.clone(), total.clone(), done.clone(), tx, ctx.clone())?;+ spawn_inspect(path.clone(), cancel.clone(), progress.clone(), tx, ctx.clone())?;app.lightroom_last = None;- app.lightroom = Some(LightroomTask { kind: Kind::Inspect, path: path.clone(), cancel, progress, rx, phase: Phase::Reading, cancelled: false });- app.lightroom = Some(LightroomTask::new(&app.session, Kind::Inspect, path.clone(), cancel, total, done, rx));++ app.lightroom = Some(LightroomTask::new(&app.session, Kind::Inspect, path.clone(), cancel, progress, rx));Ok(json!({"running": true, "kind": "inspect", "path": path}))}@@@ -255,7 -297,7 +306,7 @@@ fn start_import(app: &mut LightcraftApplet (tx, rx) = mpsc::channel();spawn_prepare(job, cancel.clone(), tx, ctx.clone())?;app.lightroom_last = None;- app.lightroom = Some(LightroomTask { kind: Kind::Import, path: path.clone(), cancel, progress, rx, phase: Phase::Reading, cancelled: false });- app.lightroom = Some(LightroomTask::new(&app.session, Kind::Import, path.clone(), cancel, total, done, rx));++ app.lightroom = Some(LightroomTask::new(&app.session, Kind::Import, path.clone(), cancel, progress, rx));Ok(json!({"running": true, "kind": "import", "path": path}))}@@@ -414,68 -457,67 +466,67 @@@ pub fn wait_for(_app: &mut LightcraftApunsupported_wasm()}- /// The progress window for inspect/import, with cancellation.- pub fn progress(app: &mut LightcraftApp, ctx: &egui::Context) {- let Some(task) = app.lightroom.as_ref() else { return };- let (step, done, total) = task.progress.step();- let title = match task.kind {- Kind::Inspect => crate::i18n::tr("Inspecting Lightroom Catalog"),- Kind::Import => crate::i18n::tr("Importing Lightroom Catalog"),- };- // The step under way, with its own count: reading the photos takes nearly all of an import.- let text = match (task.phase, step) {- (Phase::Reading, LightroomStep::Catalog) if total == 0 => crate::i18n::tr("Reading Lightroom catalog…").into(),- (Phase::Reading, LightroomStep::Catalog) => {- crate::i18n::tr_format!("Reading Lightroom catalog… {done} of {total}", done = done, total = total)- }- (Phase::Reading, LightroomStep::ReadPhotos) => crate::i18n::tr_format!("Reading photos… {} of {}", done, total),- (Phase::Reading, LightroomStep::AddPhotos) => crate::i18n::tr_format!("Adding photos… {} of {}", done, total),- (Phase::Committing, _) => crate::i18n::tr("Adding Lightroom photos…").into(),- (Phase::Finalizing, _) => crate::i18n::tr("Saving Lightroom import index…").into(),- };- // Two bars: the whole task above, the step named by `text` below. Inspecting is one step.- let reading = task.phase == Phase::Reading;- let step_fraction = if reading { done as f32 / total.max(1) as f32 } else { 1.0 };- let whole = match task.kind {- Kind::Import if reading => Some(task.progress.fraction()),- Kind::Import => Some(1.0),- Kind::Inspect => None,- };- let mut cancel = false;- let t = Tokens::get(ctx);- let height = if whole.is_some() { 140.0 } else { 92.0 };- egui::Window::new(title).title_bar(false).resizable(false).anchor(Align2::CENTER_BOTTOM, [0.0, -80.0]).fixed_size([360.0, height]).show(- ctx,- |ui| {- if let Some(whole) = whole {- ui.label(egui::RichText::new(title).color(t.text).strong());- ui.add(egui::ProgressBar::new(whole).desired_width(340.0).show_percentage());- ui.add_space(4.0);- }- ui.label(egui::RichText::new(text).color(t.text));- ui.add(egui::ProgressBar::new(step_fraction).desired_width(340.0));- let r =- ui.add_enabled(task.phase == Phase::Reading && !task.cancel.load(Ordering::Relaxed), egui::Button::new(crate::i18n::tr("Cancel")));- register(ui.ctx(), "button:lightroomCancel", r.rect);- cancel = r.clicked();- },- );- if cancel {- if let Some(task) = app.lightroom.as_mut() {- task.cancel();- }- ctx.request_repaint();- }- if app.lightroom.is_some() {- ctx.request_repaint_after(std::time::Duration::from_millis(100));- }- }-#[cfg(test)]mod tests {- use super::inspect_report;+ use super::*;use lightcraft_engine::lightroom_catalog::CatalogImport;+ /// A task as `start_import` makes it, fed by a channel the test holds instead of a worker.- fn fake_import(h: &crate::headless::Headless) -> (LightroomTask, mpsc::Sender<Message>, Arc<AtomicBool>, Arc<AtomicUsize>, Arc<AtomicUsize>) {++ fn fake_import(h: &crate::headless::Headless) -> (LightroomTask, mpsc::Sender<Message>, Arc<AtomicBool>, LightroomProgress) {+ let (tx, rx) = mpsc::channel();- let (cancel, total, done) = (Arc::new(AtomicBool::new(false)), Arc::new(AtomicUsize::new(0)), Arc::new(AtomicUsize::new(0)));- let task = LightroomTask::new(&h.app.session, Kind::Import, "fixture.lrcat".into(), cancel.clone(), total.clone(), done.clone(), rx);- (task, tx, cancel, total, done)++ let (cancel, progress) = (Arc::new(AtomicBool::new(false)), LightroomProgress::default());++ let task = LightroomTask::new(&h.app.session, Kind::Import, "fixture.lrcat".into(), cancel.clone(), progress.clone(), rx);++ (task, tx, cancel, progress)+ }++ fn demo() -> crate::headless::Headless {+ let app = crate::LightcraftApp::new(lightcraft_engine::Session::with_demo(), crate::Services { png: None, ..Default::default() });+ let mut h = crate::headless::Headless::new(app, [1200.0, 800.0], 1.0);+ // no render left running at exit (see tests_activity::demo)+ h.settle(std::time::Duration::from_secs(20));+ h+ }++ #[test]+ fn lightroom_row_is_not_cancellable_while_committing() {+ let mut h = demo();- let (task, tx, cancel, total, done) = fake_import(&h);++ let (task, tx, cancel, progress) = fake_import(&h);+ h.app.lightroom = Some(task);- total.store(10, Ordering::Relaxed);- done.store(3, Ordering::Relaxed);++ progress.catalog_total.store(10, Ordering::Relaxed);++ progress.catalog_done.store(3, Ordering::Relaxed);+ h.step();+ let rows = h.app.session.activity.list();+ assert_eq!(rows.len(), 1);+ assert_eq!((rows[0].kind, rows[0].label.as_str()), ("lightroom", "Importing Lightroom catalog"));+ assert_eq!((rows[0].done, rows[0].total), (3, 10));+ assert!(rows[0].cancellable, "reading the catalog can stop");+ h.app.lightroom.as_mut().unwrap().enter(Phase::Committing);+ let row = h.app.session.activity.list().remove(0);+ assert!(!row.cancellable, "once photos are being added it runs to the end");+ assert!(h.app.session.activity.cancel(row.id).is_err());+ assert!(!cancel.load(Ordering::Relaxed));+ tx.send(Message::Finalized(Ok(()))).unwrap();+ h.step();+ assert!(h.app.lightroom.is_none());+ assert!(h.app.session.activity.list().is_empty(), "the row goes with the task");+ }++ #[test]+ fn lightroom_cancel_from_the_stack_stops_the_read() {+ let mut h = demo();- let (task, tx, cancel, _, _) = fake_import(&h);++ let (task, tx, cancel, _) = fake_import(&h);+ h.app.lightroom = Some(task);+ h.step();+ let id = h.app.session.activity.list()[0].id;+ h.app.session.activity.cancel(id).unwrap();+ assert!(cancel.load(Ordering::Relaxed), "the worker sees the stack's ✕");+ tx.send(Message::Prepared(Err("cancelled".into()))).unwrap();+ h.step();+ assert!(h.app.lightroom.is_none());+ assert_eq!(h.app.lightroom_last, Some(serde_json::json!({"cancelled": true, "path": "fixture.lrcat"})));+ assert!(h.app.session.activity.list().is_empty());+ }+#[test]fn inspect_report_keeps_empty_catalog_shape() {let report = inspect_report(CatalogImport {