mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-08-07 14:30:15 -03:00
feat(example-images): add missing-only download path and skip existing files
Split the single-model and bulk context menu actions into 'Download Missing Example Images' (regular endpoint, skips already-processed models) and 'Re-process Example Images' (force endpoint, retries failed models). - start_download accepts model_hashes so a selected subset can be processed with the progress-aware skip logic; explicitly targeted models bypass the failed/processed model-level guards so per-image gaps are filled - pre-download existence check in the processor skips network requests for image files already on disk across all download paths - force download retries previously failed models and clears their failed status on success - add i18n keys for the new menu items across all locales
This commit is contained in:
@@ -144,6 +144,12 @@ export class BulkContextMenu extends BaseContextMenu {
|
||||
downloadExampleImagesItem.style.display = modelPages.includes(currentModelType) ? 'flex' : 'none';
|
||||
}
|
||||
|
||||
const downloadMissingExampleImagesItem = this.menu.querySelector('[data-action="download-missing-example-images"]');
|
||||
if (downloadMissingExampleImagesItem) {
|
||||
// Show on model pages (loras, checkpoints, embeddings), hide on recipes
|
||||
downloadMissingExampleImagesItem.style.display = ['loras', 'checkpoints', 'embeddings'].includes(currentModelType) ? 'flex' : 'none';
|
||||
}
|
||||
|
||||
const skipMetadataRefreshItem = this.menu.querySelector('[data-action="skip-metadata-refresh"]');
|
||||
const resumeMetadataRefreshItem = this.menu.querySelector('[data-action="resume-metadata-refresh"]');
|
||||
|
||||
@@ -294,8 +300,11 @@ export class BulkContextMenu extends BaseContextMenu {
|
||||
case 'download-missing-loras':
|
||||
this.handleDownloadMissingLoras();
|
||||
break;
|
||||
case 'download-missing-example-images':
|
||||
this.handleDownloadExampleImages({ force: false });
|
||||
break;
|
||||
case 'download-example-images':
|
||||
this.handleDownloadExampleImages();
|
||||
this.handleDownloadExampleImages({ force: true });
|
||||
break;
|
||||
case 'clear':
|
||||
bulkManager.clearSelection();
|
||||
@@ -340,7 +349,7 @@ export class BulkContextMenu extends BaseContextMenu {
|
||||
await bulkMissingLoraDownloadManager.downloadMissingLoras(selectedRecipes);
|
||||
}
|
||||
|
||||
async handleDownloadExampleImages() {
|
||||
async handleDownloadExampleImages({ force = true } = {}) {
|
||||
if (state.selectedModels.size === 0) {
|
||||
return;
|
||||
}
|
||||
@@ -361,7 +370,7 @@ export class BulkContextMenu extends BaseContextMenu {
|
||||
|
||||
try {
|
||||
const apiClient = getModelApiClient();
|
||||
await apiClient.downloadExampleImages([...hashes]);
|
||||
await apiClient.downloadExampleImages([...hashes], null, { force });
|
||||
} catch (error) {
|
||||
console.error('Bulk download example images failed:', error);
|
||||
}
|
||||
|
||||
@@ -347,7 +347,10 @@ export const ModelContextMenuMixin = {
|
||||
openExampleImagesFolder(this.currentCard.dataset.sha256);
|
||||
return true;
|
||||
case 'download-examples':
|
||||
this.downloadExampleImages();
|
||||
this.downloadExampleImages(false);
|
||||
return true;
|
||||
case 'download-examples-force':
|
||||
this.downloadExampleImages(true);
|
||||
return true;
|
||||
case 'civitai':
|
||||
if (this.currentCard.dataset.from_civitai === 'true') {
|
||||
@@ -378,7 +381,7 @@ export const ModelContextMenuMixin = {
|
||||
},
|
||||
|
||||
// Download example images method
|
||||
async downloadExampleImages() {
|
||||
async downloadExampleImages(force = false) {
|
||||
const modelHash = this.currentCard.dataset.sha256;
|
||||
if (!modelHash) {
|
||||
showToast('toast.contextMenu.missingHash', {}, 'error');
|
||||
@@ -387,7 +390,7 @@ export const ModelContextMenuMixin = {
|
||||
|
||||
try {
|
||||
const apiClient = getModelApiClient();
|
||||
await apiClient.downloadExampleImages([modelHash]);
|
||||
await apiClient.downloadExampleImages([modelHash], null, { force });
|
||||
} catch (error) {
|
||||
console.error('Error downloading example images:', error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user