Skip to content

feat: add sorting by file size#1330

Open
baracchande wants to merge 1 commit intoTagStudioDev:mainfrom
baracchande:feat/sort-by-file-size
Open

feat: add sorting by file size#1330
baracchande wants to merge 1 commit intoTagStudioDev:mainfrom
baracchande:feat/sort-by-file-size

Conversation

@baracchande
Copy link

Summary

core/library/alchemy/enums.py: Added SIZE = "file.size" to SortingModeEnum

core/library/alchemy/library.py

  • search_library(): when SIZE mode is active, skips SQL ordering (falls back to Entry.id) and calls _sort_ids_by_file_size() after the query returns.
  • New method _sort_ids_by_file_size(): bulk-fetches all entry paths in one query, calls stat().st_size on each file, returns the IDs sorted by size. Missing/unlinked files get size -1 and sort to the front (ascending).

Added "file.size" key with a proper translation in each translation file.

tests/test_search.py: Four new tests.

This implements the file size sort option requested in 207

Tasks Completed

  • Platforms Tested:
    • Windows x86
    • Windows ARM
    • macOS x86
    • macOS ARM
    • Linux x86
    • Linux ARM
  • Tested For:
    • Basic functionality
    • PyInstaller executable

@TrigamDev TrigamDev added Type: Enhancement New feature or request Status: Review Needed A review of this is needed Type: File System File system interactions TagStudio: Search The TagStudio search engine labels Mar 5, 2026
Comment on lines +1092 to +1094
if is_size_sort:
ids = self._sort_ids_by_file_size(ids, search.ascending)

Copy link
Collaborator

Choose a reason for hiding this comment

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

This breaks when the query has a LIMIT due to the page size.

@Computerdores
Copy link
Collaborator

Also, unless you speak 19 languages those are AI/machine translations and I would prefer not having those in here.

Because while I'm not sure whether we have an official policy on AI/machine translations, I would personally prefer a high quality of translations over a high quantity (and people are less likely to contribute when translations are suboptimal rather than missing), so I would prefer a missing translation over an AI one (also should we redecide in the future we can do the AI translations ourselves, where as we won't have any idea how good our translations are if we allow AI translations).

@TrigamDev TrigamDev added Status: Changes Requested Changes are requested to this and removed Status: Review Needed A review of this is needed labels Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Changes Requested Changes are requested to this TagStudio: Search The TagStudio search engine Type: Enhancement New feature or request Type: File System File system interactions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants