Skip to content

[Feature Request]: Optimize _match_missing_file #610

Description

@Toby222

Checklist

  • I am using an up-to-date version.
  • I have read the documentation.
  • I have searched existing issues.

TagStudio Version

Alpha 9.4.0+

Operating System & Version

NixOS unstable

Description

the Search & Relink feature for missing files is incredibly slow for larger libraries, since for every missing entry it walks the library directory again. Extremely noticeable on larger library.

(I noticed this when reorganizing my photos folder from YYYY/ folders to YYYY/MM/DD/ folders, so there were ~11000 moved files)

Expected Behavior

The list of files in the library should be cached between calls to _match_missing_file to speed up unlinked entry Relinking.
In a bodge solution I added a simple member _cache to the Library class, and in _match_missing_file initialize it with the result of os.walk, if not already set.

Steps to Reproduce

  1. Create a library with a lot of entries
  2. Move multiple files to a new directory
  3. Search & Relink the now-missing entries
  4. Observe that between every entry a second or more can pass

Logs

No response

Activity

  1. CyanVoxel commented on Nov 28, 2024

    @CyanVoxel
    Member

    I would call this more of a request/need for optimization than a bug since the code is working as intended, but I do agree that this area of the code could really use some optimizing.

  2. Toby222 commented on Nov 28, 2024

    @Toby222
    ContributorAuthor

    Between feature request and bug, I felt like "doesn't work as it should" fit better than "doesn't work like how I want"
    There's no clear category for where to put performance issues over stuff that actually breaks something :^)

  3. changed the title [-][Bug]: _match_missing_file walks library for every missing file[/-] [+][Feature Request]: Optimize _match_missing_file[/+] on Dec 5, 2024
  4. added
    Type: QoLA quality of life (QoL) enhancement or suggestion
    and removed
    Type: BugSomething isn't working as intended
    on Dec 5, 2024
  5. dominic248 commented on Jan 11, 2026

    @dominic248

    Hi @CyanVoxel for auto-relink of files on rename or moved files, we can have...

    1. a prefix in the filename like id of file in DB (drawbacks - if user removes the prefix, then manual linking is needed)
    2. hash value of file (drawbacks - if file is edited then hash value will change and manual linking is needed)
    3. combination of both prefix id & hash value for auto-relink, incase user mistakenly deleted the prefix , then the program can rename the file & add prefix, based on the hash match (drawbacks - file with same hash/duplicate files)
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

    Type: FeatureNew feature or requestType: QoLA quality of life (QoL) enhancement or suggestion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions