When a folder is removed from the library, images under that folder are
now properly cleaned up from the database if they are not covered by any
other registered paths. This fixes the issue where Random Image would
pull from folders that had been removed.
The cleanup logic checks if each image is still "owned" by any remaining
scanned path before deletion, supporting nested path scenarios where a
parent path may still contain the images.
Fixes#868
Co-Authored-By: Claude <noreply@anthropic.com>
- Tag.get_or_create now returns None for invalid tag names instead of creating error tags
- Add null checks before using tag.id in all callers
- Adjust tag validation: non-Chinese tags now limited to 8 words or 40 characters
- Change Tag.get_or_create to return None for invalid tag names
- Add None checks at all call sites to prevent AttributeError
- Protects against invalid Chinese names (>16 chars) and other language names (>8 words)
- Ensures system stability when encountering problematic tag data
Important performance optimization for handling large tag datasets:
- When total tags > 8192, limit 'pos' type tags to top 4096 by count
- Return all non-pos tags without limitation
- Significantly reduces memory usage and load time for large databases
- Maintains functionality while improving performance with massive tag counts
- Add tag name validation in Tag.get_or_create method
- Chinese names: max 16 characters
- Other languages: max 8 words
- Return error tags with uppercase English names when validation fails
- Ensure error tags are created through get_or_create to maintain database consistency
- Clean up database: removed 487,938 non-custom tags, keeping only 12 custom tags
- Add keyword count limit (default 600) for Tag layer to improve performance
- Implement irregular node layout with random perturbations
- Add layer spacing based on adjacent layer widths for consistent gaps
- Add cache result banner with collapse/expand functionality
- Add streaming response utility for LLM API calls
- Update i18n translations for new cache banner texts
- Optimize tag graph: increase max tags to 500, add level-2 tiered requirements
- Fix keyword deduplication and null handling in tag graph
- Add get_all_keywords_frequency method to TopicTitleCache
- Initialize keyword frequency from historical cached cluster keywords
- Prioritize top 100 high-frequency keywords when generating new keywords
- Update LLM prompt to prefer existing keywords from frequency list
- Reduce duplicate/similar keyword generation across clusters
- Add streaming support for tag_graph LLM requests
- Increase LLM timeout and retry limits for better reliability
- Add audio file recognition in backend (tool.py) and frontend (file.ts)
- Support audio formats: mp3, wav, ogg, flac, m4a, aac, wma
- Add audio player in TikTok view with starfield background animation
- Add audio modal similar to video modal
- Update file type filter to multi-select checkboxes (image/video/audio)
- Add filename display in TikTok view with Douyin-style bottom gradient
- Add long press to hide/show controls in TikTok view
- Fix audio resource cleanup when closing TikTok view
- Add Audio media type tag in database indexing
- Add i18n translations for audio related strings
Backend optimizations:
- Refactor get_random_images() using SQLite ORDER BY RANDOM()
- Simplify from 60+ lines to ~20 lines with better performance
- Remove complex multi-cycle index calculations
- Maintain file existence check and auto-cleanup
ComfyUI support:
- Add fallback to 'parameters' field in PNG metadata
- Improve detection for ComfyUI-generated images
Frontend improvements:
- Smart prompt display: auto-detect tag vs natural language format
- Add getTextLength() with Chinese character weight (1 char = 3 letters)
- Refactor isTagStylePrompt() with clear rules:
* Any tag length > 50 natural language format
* Average tag length > 30 natural language format
- Natural language prompts shown as paragraphs
- Tag-style prompts shown as badges
- Better support for Chinese/English mixed content
Build:
- Update frontend asset references
- Add AutoTagMatcher singleton class for automatic tag application
- Support filtering by multiple fields (prompt, model, sampler, etc.)
- Add frontend UI for managing auto-tag rules in global settings
- Support AND logic for multiple conditions within a rule
- Integrate with image indexing process
- Add natural language vs tag-style prompt detection and rendering
- Include rule descriptions and usage guidance in UI
- Auto-reload rules when updated via API
- Added video tag support for enhanced media file handling:
* Video files can now use tag-based search functionality
* Added support for reading video generation info from txt files
* Enhanced EXIF data handling for video media types
- Implemented random sort feature for image grid:
* Added random sort toggle button with visual indicators (🎲/📅)
* Supports both random and date-based sorting modes
* Optimized pagination for random sorting with offset-based cursors
- Complete internationalization support:
* Added translations for random sort and date sort in all languages
* Supported languages: zh-hans, en, de, zh-hant
* Improved UI consistency across language variants
- Backend improvements:
* Enhanced database queries to support random sorting
* Added random_sort parameter to API endpoints
* Improved error handling for video file processing
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>