mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-10-07 18:12:12 -03:00
Refreshing had no way to say "scan only this drive": a user with three external
drives had to spin all of them up for every refresh, and switching a drive off
made the next refresh treat its whole library as deleted (rows pruned from the
memory cache and the SQLite cache, preview_url stripped on the next scroll).
Backend (py/services/model_scanner.py, py/config.py):
* ReconcileScope(roots, folder) + _reconcile_cache(scope=...): files inside the
scope reconcile normally, everything outside is neither re-read nor removed.
The folder half is plumbing for the sidebar entry in the next change.
* Path-level pruning guard: cached entries under a path this walk could not
read are kept and reported instead of removed. Sources: a configured root that
is not reachable (drive switched off while LM runs), a directory os.walk
failed to enter (permissions / I/O error / Windows junction to an offline
drive), and a known first-level symlink whose target is gone
(Config.iter_path_mappings()).
* The recorded folder list is unioned instead of replaced whenever the scan did
not verify every root, so a scoped scan cannot empty the sidebar.
* _reconcile_cache returns a summary (added / removed / repaired /
scanned_roots / skipped_roots / unavailable_paths / kept_unreachable),
exposed as ModelScanner.last_reconcile_summary, returned by
BaseModelService.scan_models() and broadcast in the completed WS payload.
* _root_display_labels(): set-aware labels ("G: loras", "usb/loras") grown
leftwards with real parent segments until unique, shared by the walk-progress
line and the roots API.
* GET /scan accepts repeated `roots` (400 for unknown roots, 400 combined with
full_rebuild=true); GET /roots gains root_details (label / reachable / cached
count) while `roots` stays a plain path list for existing callers.
* serve_preview: a 404 no longer clears the cached preview_url when the file's
own directory is unreachable - browsing the grid with a drive off used to
strip preview references from the persistent cache.
Frontend:
* Refresh ▾ gains a "Scan one folder" section listing the page's roots with
their cached counts; offline roots stay clickable and explain themselves; rows
are wired by delegation (new static/js/components/controls/ScanScopeMenu.js).
* A scoped scan reports "Scanned <root>: N new, M removed"; a scan that kept
entries reports "<N> models kept: <paths> not reachable".
* registerAPI() now injects the two cross-page passthroughs (fetchModelRoots and
an argument-forwarding refreshModels) so a page facade cannot drop them: the
first version rendered an empty menu and would have run a full refresh.
* createToastElement whitelists toast types, so a wrong `type` argument degrades
to the info style instead of rendering an unstyled box.
Verified in a sandbox instance with three roots: a scoped scan walks only the
requested root (progress roots=0/1, 240 files); a full refresh with one root
offline reports kept_unreachable=60 and leaves all 420 models cached; /roots
reports the offline root with its cached count. 3699 passed, 7 skipped;
frontend 1488 passed (148 files); vue widgets 96 passed.
124 lines
4.4 KiB
JavaScript
124 lines
4.4 KiB
JavaScript
// CheckpointsControls.js - Specific implementation for the Checkpoints page
|
|
import { PageControls } from './PageControls.js';
|
|
import { getModelApiClient, resetAndReload } from '../../api/modelApiFactory.js';
|
|
import { getSessionItem, removeSessionItem } from '../../utils/storageHelpers.js';
|
|
import { downloadManager } from '../../managers/DownloadManager.js';
|
|
|
|
/**
|
|
* CheckpointsControls class - Extends PageControls for Checkpoint-specific functionality
|
|
*/
|
|
export class CheckpointsControls extends PageControls {
|
|
constructor() {
|
|
// Initialize with 'checkpoints' page type
|
|
super('checkpoints');
|
|
|
|
// Register API methods specific to the Checkpoints page
|
|
this.registerCheckpointsAPI();
|
|
|
|
// Check for custom filters (e.g., from recipe navigation)
|
|
this.checkCustomFilters();
|
|
}
|
|
|
|
/**
|
|
* Register Checkpoint-specific API methods
|
|
*/
|
|
registerCheckpointsAPI() {
|
|
const checkpointsAPI = {
|
|
// Core API functions
|
|
loadMoreModels: async (resetPage = false, updateFolders = false) => {
|
|
return await getModelApiClient().loadMoreWithVirtualScroll(resetPage, updateFolders);
|
|
},
|
|
|
|
resetAndReload: async (updateFolders = false) => {
|
|
return await resetAndReload(updateFolders);
|
|
},
|
|
|
|
|
|
// Add fetch from Civitai functionality for checkpoints
|
|
fetchFromCivitai: async () => {
|
|
return await getModelApiClient().fetchCivitaiMetadata();
|
|
},
|
|
|
|
// Add show download modal functionality
|
|
showDownloadModal: () => {
|
|
downloadManager.showDownloadModal();
|
|
},
|
|
|
|
toggleBulkMode: () => {
|
|
if (window.bulkManager) {
|
|
window.bulkManager.toggleBulkMode();
|
|
} else {
|
|
console.error('Bulk manager not available');
|
|
}
|
|
},
|
|
|
|
clearCustomFilter: async () => {
|
|
await this.clearCustomFilter();
|
|
}
|
|
};
|
|
|
|
// Register the API
|
|
this.registerAPI(checkpointsAPI);
|
|
}
|
|
|
|
/**
|
|
* Check for custom filters sent from other pages (e.g., recipe modal)
|
|
*/
|
|
checkCustomFilters() {
|
|
const filterCheckpointHash = getSessionItem('recipe_to_checkpoint_filterHash');
|
|
const filterRecipeName = getSessionItem('filterCheckpointRecipeName');
|
|
|
|
if (filterCheckpointHash && filterRecipeName) {
|
|
const indicator = document.getElementById('customFilterIndicator');
|
|
const filterText = indicator?.querySelector('.customFilterText');
|
|
|
|
if (indicator && filterText) {
|
|
indicator.classList.remove('hidden');
|
|
|
|
const displayText = `Viewing checkpoint from: ${filterRecipeName}`;
|
|
filterText.textContent = this._truncateText(displayText, 30);
|
|
filterText.setAttribute('title', displayText);
|
|
|
|
const filterElement = indicator.querySelector('.filter-active');
|
|
if (filterElement) {
|
|
filterElement.classList.add('animate');
|
|
setTimeout(() => filterElement.classList.remove('animate'), 600);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Clear checkpoint custom filter and reload
|
|
*/
|
|
async clearCustomFilter() {
|
|
// Check for View Local Versions filter first
|
|
const vlmModelId = getSessionItem('vlm_model_id');
|
|
if (vlmModelId) {
|
|
removeSessionItem('vlm_model_id');
|
|
removeSessionItem('vlm_model_name');
|
|
removeSessionItem('vlm_base_model');
|
|
removeSessionItem('vlm_page_type');
|
|
this._restoreSortAfterVlm();
|
|
// Hide the indicator
|
|
const indicator = document.getElementById('customFilterIndicator');
|
|
if (indicator) {
|
|
indicator.classList.add('hidden');
|
|
}
|
|
await resetAndReload();
|
|
return;
|
|
}
|
|
|
|
removeSessionItem('recipe_to_checkpoint_filterHash');
|
|
removeSessionItem('recipe_to_checkpoint_filterHashes');
|
|
removeSessionItem('filterCheckpointRecipeName');
|
|
|
|
const indicator = document.getElementById('customFilterIndicator');
|
|
if (indicator) {
|
|
indicator.classList.add('hidden');
|
|
}
|
|
|
|
await resetAndReload();
|
|
}
|
|
}
|