-
-
Notifications
You must be signed in to change notification settings - Fork 81
feat(move): add {original_path} placeholder for preserving folder structure #571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ucture
Adds support for {original_path} placeholder in path templates, allowing users
to preserve existing custom folder structures when moving or auto-organizing models
across different drives or directories.
Features:
- New {original_path} placeholder extracts relative path from model root
- Works in both Move modal and Auto-Organize settings
- Combines with other placeholders (e.g., {base_model}/{original_path})
- Combines with folder browser selection in Move modal
- Includes validation and preview support in Settings
Backend changes:
- Extended calculate_relative_path_for_model() to support {original_path}
- Added model_type parameter to ModelMoveService for template processing
- Updated auto-organize to pass model_roots for path calculation
- Added path_template parameter to move endpoints
Frontend changes:
- Added path template input field to Move modal
- Updated placeholder validation in constants.js
- Enhanced SettingsManager preview to show {original_path} examples
- Modified MoveManager to combine folder selection with templates
Manual verification:
- Tested moving models with {original_path} template
- Tested auto-organize with {original_path} in download path settings
- Verified template validation and preview display
- Confirmed folder browser + template combination works correctly
|
Quick Q: does this (or the existing functionality) verify that the target folderpath/filename.ext length does not exceed the max pathlength for the filesystem? NTFS is particular about this for most of the API calls using standard system settings. I think the maximum is 260 chars. |
I don't know If I have made any checks about maximum target path in this PR implementation. I would have to check. |
Path Length Validation Implemented@brendanhoar Thanks for raising this concern! I've added filesystem path length validation to address the NTFS 260-character limit issue. What was implemented:Backend:
Frontend:
How it works:When a user attempts to move a model or use auto-organize, the system now:
The validation is platform-aware (defaults to 260 for Windows NTFS, but can be adjusted for other filesystems). Commit: |
Adds validation to prevent filesystem path length limit violations (260 chars for Windows NTFS). Validation is performed at three levels: 1. Backend utility function validate_path_length() in utils.py 2. Auto-organize operations in ModelFileService._process_single_model() 3. Individual model moves in ModelMoveService.move_model() 4. Frontend validation in MoveManager.moveModel() before API call When path exceeds limit, users get clear error messages showing actual vs allowed length. Addresses GitHub comment on PR willmiao#571 regarding filesystem constraints.
Adds validation to prevent filesystem path length limit violations (260 chars for Windows NTFS). Validation is performed at three levels: 1. Backend utility function validate_path_length() in utils.py 2. Auto-organize operations in ModelFileService._process_single_model() 3. Individual model moves in ModelMoveService.move_model() 4. Frontend validation in MoveManager.moveModel() before API call When path exceeds limit, users get clear error messages showing actual vs allowed length. Addresses GitHub comment on PR willmiao#571 regarding filesystem constraints.
10d7eb7 to
b6feb3c
Compare
Problem
Users need to move models between drives for backup/organization while preserving their existing custom folder structures. For example, moving models from
Models\Lora\Clothes\Pantsto a new drive atSD1.5\Lora\Clothes\Pantswhile maintaining the custom subfolder organization.Solution
Added
{original_path}placeholder support to the existing path template system. This placeholder extracts the relative folder path from the model's current location (excluding the filename) and can be combined with other placeholders.Usage Examples
Move Modal:
{original_path}→ Preserves current folder structure{base_model}/{original_path}→ Adds base model prefix to current structureAuto-Organize (Settings → Download Paths):
{base_model}/{original_path}for structured organizationImplementation Details
Backend Changes
py/utils/utils.py: Extendedcalculate_relative_path_for_model()to support{original_path}placeholder usingos.path.relpath()py/services/model_file_service.py:model_typeparameter toModelMoveService.__init__()move_model()to accept and processpath_templateparametermodel_rootsfor{original_path}calculationpy/routes/base_model_routes.py: FixedModelMoveServiceinstantiation to passmodel_typepy/routes/handlers/model_handlers.py: Addedpath_templateparameter extraction from request JSONFrontend Changes
static/js/utils/constants.js: Added{original_path}toPATH_TEMPLATE_PLACEHOLDERSfor validationstatic/js/managers/MoveManager.js:static/js/api/baseModelApi.js: Updated API methods to sendpath_templateparameterstatic/js/managers/SettingsManager.js: Updated preview logic to show{original_path}examplestemplates/components/modals/move_modal.html: Added path template input field with help texttemplates/components/modals/settings_modal.html: Added{original_path}to placeholder documentationlocales/en.json: Added translation keys for new UI elementsManual Verification
✅ Tested moving models with
{original_path}template✅ Tested the "Source and target directories are the same" scenario
✅ Tested combining folder browser with template
✅ Tested
{base_model}/{original_path}in auto-organize settings✅ Verified validation error and fix for
{original_path}placeholderNotes
{original_path}extracts the current relative path from the model root, not a "first-seen" path{original_path}, it will include the current organization in the new pathFiles Changed
py/utils/utils.pypy/services/model_file_service.pypy/routes/base_model_routes.pypy/routes/handlers/model_handlers.pystatic/js/utils/constants.jsstatic/js/managers/MoveManager.jsstatic/js/managers/SettingsManager.jsstatic/js/api/baseModelApi.jstemplates/components/modals/move_modal.htmltemplates/components/modals/settings_modal.htmllocales/en.json