Skip to content

Library folders: photo paths relative to a root, and Update Folder Location (a moved disk or folder is one change) #1116

Open

Description

@mattsivak

Problem (today, on one machine)

Every library photo stores an absolute path (Source::File { path }). When a disk or folder turns up somewhere else, every photo under it goes missing:

  • a USB disk or NAS comes back at a new drive letter or mount point (D: → E:, /Volumes/tokyo → /Volumes/tokyo 1, /media/me/usb → /run/media/me/usb): Find Missing has to find every photo again, by name, size and content hash;
  • the same disk written two ways shows as two disks (/Volumes/tokyo and /Volumes/TOKYO, LRC-LIB-LIBFOLDERS Limits);
  • a folder moved outside LightCraft loses its colour label: Find Missing relinks photos but not folder records (same Limits);
  • The [Synchronize Folder] dialog should provide an option to locate the new path if folder is missing #1112: Synchronize Folder on a missing folder has no way to say where it went.

Lightroom Classic's answer is Update Folder Location / Find Missing Folder on a folder row: one change and everything under it follows. This issue proposes the same thing for LightCraft.

It's useful today, on a single machine, without any sync. It's also the per-device path mapping that multi-machine libraries (#294, #880) will need later, but nothing here depends on that plan or builds towards a sync format (no device ids, no clocks). It isn't a #641-style step that has no use yet.

Design

Roots. The catalog keeps a table of roots, Root { id, path, volume_name? }. A photo's location becomes (root, relative path). A root's path is where it is on this machine; volume_name (the mount or volume label as seen at import) is only kept for a later "this disk is back at E:" prompt.

  • On import, a photo goes under the deepest existing root that contains it; otherwise a new root is made at its disk (folders::volume_of: D:, //server/share, /Volumes/tokyo, /media/me/usb …). On the startup disk the root is / (or C:), until someone moves a folder there (below).
  • The web build keeps one root for its OPFS storage. Local browse records (not library photos) stay on absolute paths.

One function. The only place that turns a location into a path is Catalog::file_path(&Photo) -> Option<PathBuf> (root.path + relative, joined with the separators the root uses). The engine, UI, web and CLI call it and never join paths themselves.

Ops.

  • AddRoot { root } / RemoveRoot: made automatically on import and when a folder needs a root of its own.
  • SetRootPath { root, path }: one undo step; its inverse is the old path. Every photo under the root follows, and so do its folder records (colour labels), smart-album folder rules and the shown libraryFolder source, because they're stored root-relative too. Nothing is rewritten photo by photo, so it's O(1) whatever the root holds.
  • Moving a folder that isn't a root (e.g. ~/Pictures/2019 moved on the startup disk): one Batch splits off a new root at that folder (re-homing the photos and folder records under it) and then sets its path. It's still one undo step.
  • Moving a root onto an existing root's path (the tokyo / TOKYO case) merges the two, also one step and undoable. Paths are still compared as written. Case-folding stays with the OS (Windows folds case); merging is something the user chooses.
  • Op::Relink, Op::SetFile, rename and Convert to DNG keep taking absolute paths. The catalog maps them into (root, relative) when it applies them, so engine call sites and the ops already in logs don't change shape.

Commands (everything is a command): folder.updateLocation { folder, path } (works on any folder or disk row; the folder or disk need not be mounted now) and library.roots (list roots with their paths and whether each is there). They come with menu entries:

MCP and CLI get these through the same ids.

Older libraries (format)

Plan: small PRs, each useful and green on its own

  1. One path function, no format change. Add Catalog::file_path and move the ~98 non-test reads of Source::File { path } (~35 files: rename.rs, import.rs, cmd/convert.rs, media.rs, wire.rs …) onto it. The behaviour is identical. This keeps the format PR small and stops new code from joining paths.
  2. Catalog roots: the root table, (root, relative) storage, loading older logs, format bump, the tests above. The behaviour is still identical.
  3. SetRootPath + folder.updateLocation + library.roots, with undo; folder records, smart-album folder rules and the shown folder follow. Update the LRC-LIB-LIBFOLDERS / LRC-LIB-MISSING Limits, add a checklist row for Update Folder Location, and update docs/gaps.md / whats-new.md.
  4. UI: the menu entries, Missing Photos and the Synchronize Folder hook (The [Synchronize Folder] dialog should provide an option to locate the new path if folder is missing #1112), checked by screenshots through the control channel.
  5. (Optional, later) when a root is missing and a mounted disk has the same volume name, offer "tokyo is now at E:\ — update?". This only ever asks; it never relinks by itself.

Questions for @bflatastic / @echelon

  1. Go-ahead for this direction, starting with PR 0?
  2. Should roots default to the disk (as above, like Lightroom's top-level folders) or to the import folder? The disk keeps the root table small and makes a moved drive one action. Folder moves are covered by splitting a root on demand.
  3. Fine to wait on the format number until Catalog: the log is compacted by the snapshot's size, not every 2000 records #800/Catalog: the snapshot in segments of about 2 MB and at most 4096 photos (format 11, stacked on #800) #814 settle, or would you rather this went before them?

Related: #294, #880 (later users of the same mapping), #1112, #641 (held; this doesn't touch ids), #667 (Lightroom catalog import already finds moved .lrcat root folders; those root folders could become LightCraft roots directly).

Activity

  1. mattsivak commented on Oct 11, 2026

    @mattsivak
    ContributorAuthor

    First step is up as a draft: #1121 (folder.updateLocation, engine + tests + docs). While writing it, I found that the existing relink + folder-record machinery (what Rename / Move Folder use) already gives the user-visible result, so this step needs no new op and no catalog format change. It can't collide with #800 / #814 / #974. The root table in the proposal above can come later if you want it for #880 or for compact whole-disk moves. The sidebar entries (Update Folder Location…, and Find Missing Folder… from Synchronize, #1112) follow in a stacked PR.

  2. nledford commented on Oct 11, 2026

    @nledford
    Contributor

    I had #1112 in progress when this was posted, so there is now a PR for the user-facing half without a format change: #1122.

    It does what steps 2 and 3 here describe, by relinking photo by photo in one undo step instead of moving a root:

    • Update Folder Location… on folder and disk rows, and Locate Missing Folder… as the button of Synchronize Folder's "folder isn't there" result.
    • I took your command id, folder.updateLocation {folder, path} (plus disk? and incomplete?), so roots can replace the implementation under it later without changing what agents call. It has no library.roots.
    • Paths are mapped by folder identity (folder_rest), so a D:\Photos\… catalog is located on Linux and macOS.

    Two things in it that I think roots would still need on top:

    • A check that it is the folder. The photos' files are looked for at the new place first, off the UI thread: none there is refused, only some asks. Choosing one level too high was the easy mistake.
    • One record per file. If the new place was browsed in Local, its files have Local records, and the Synchronize scan afterwards offered every file as new. Untouched Local records give way in the same undo step; touched ones refuse it.

    It doesn't touch how paths are stored, so it shouldn't get in the way of your PR 0 or 1. If you'd rather it were shaped differently so that roots slot in more easily (the command's result, the FolderMove { on_disk } flag on the undo step), say so on #1122.

  3. Eliksir67 commented on Nov 8, 2026

    @Eliksir67

    A related case at catalog import, in case it is useful here.

    Investigated and written with Claude Code.

    A Lightroom catalog made on Windows records its originals under E:/Raw/. Imported on Linux, where the same originals are on a NAS share mounted at another path, every photo of that root folder comes in missing: about 75,000 originals for one catalog. Finding them afterwards with Find Missing Photos would mean reading every file again over the network, although the import had just been through the same catalog and could have read them in place.

    Would it make sense to let the new location of each root folder be given while the catalog is imported, before its originals are read, perhaps alongside the review of network sources in #3725? Update Folder Location would still cover a folder that moves later, but at import the photos would be linked from the start.

    Thx a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions