Skip to content

Conversation

@TheBobBobs
Copy link
Contributor

Summary

Optimize the way unlinked entries are calculated and move logic into Library scanning since it can be quickly calculated with data from scan.

Scanning a library is now split into 3 steps.

  1. Fetch all existing entry paths with ids. Collect into a dict[str, int] and set[str]
  2. Using ripgrep or wcmatch get all valid files in library dir. Collect into set[str]
  3. Use set operations to calculate which paths are new or missing.

If there are any missing paths the unlinked entries ui will be opened.
When the unlinked ui is closed new entries will automatically be saved if there are no remaining missing paths.

Tasks Completed

  • Platforms Tested:
    • Windows x86
    • Linux x86
  • Tested For:
    • Basic functionality

@CyanVoxel CyanVoxel added Type: Refactor Code that needs to be restructured or cleaned up TagStudio: Library Relating to the TagStudio library system Type: Performance An issue or change related to performance Status: Review Needed A review of this is needed labels Dec 12, 2025
@CyanVoxel CyanVoxel moved this to 👀 In review in TagStudio Development Jan 22, 2026
@CyanVoxel CyanVoxel added this to the Alpha v9.5.x milestone Jan 22, 2026
Copy link
Member

@CyanVoxel CyanVoxel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this! This tremendously speeds up the relinking process, and I like the addition of the Unlinked Entries modal automatically popping up when there's unlinked entries present. Probably something good to have as a user option, but that's fine as a future PR.

So far there's just a couple nitpicks and issues I have:

In src/tagstudio/core/library/refresh.py there's now some explicit SQLAlchemy imports which should not be used outside of the /library/alchemy directory. Since moving the affected logic to other files such as library.py would likely be cumbersome, another option could be to just move src/tagstudio/core/library/refresh.py to src/tagstudio/core/library/alchemy/refresh.py. That way there's no explicit SLQAlchemy dependencies being combined with generic code.

When refreshing the unlinked entries, the value in the "Library Information" panel is no longer updated:
image

@CyanVoxel CyanVoxel removed the Status: Review Needed A review of this is needed label Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

TagStudio: Library Relating to the TagStudio library system Type: Performance An issue or change related to performance Type: Refactor Code that needs to be restructured or cleaned up

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

2 participants