mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 15:15:44 -03:00
Enhance migration and download processes: add backend path update and prevent duplicate completion toasts
This commit is contained in:
@@ -1158,8 +1158,6 @@ class MiscRoutes:
|
|||||||
"""
|
"""
|
||||||
matching_files = []
|
matching_files = []
|
||||||
model_name = os.path.splitext(model_filename)[0]
|
model_name = os.path.splitext(model_filename)[0]
|
||||||
if model_name == "FluxMechaKnights":
|
|
||||||
logger.info(f"Processing model: {model_name}")
|
|
||||||
|
|
||||||
# Check if pattern contains a directory separator
|
# Check if pattern contains a directory separator
|
||||||
has_subdirs = '/' in regex_pattern.pattern or '\\\\' in regex_pattern.pattern
|
has_subdirs = '/' in regex_pattern.pattern or '\\\\' in regex_pattern.pattern
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ class ExampleImagesManager {
|
|||||||
this.isProgressPanelCollapsed = false;
|
this.isProgressPanelCollapsed = false;
|
||||||
this.pauseButton = null; // Store reference to the pause button
|
this.pauseButton = null; // Store reference to the pause button
|
||||||
this.isMigrating = false; // Track migration state separately from downloading
|
this.isMigrating = false; // Track migration state separately from downloading
|
||||||
|
this.hasShownCompletionToast = false; // Flag to track if completion toast has been shown
|
||||||
|
|
||||||
// Initialize download path field and check download status
|
// Initialize download path field and check download status
|
||||||
this.initializePathOptions();
|
this.initializePathOptions();
|
||||||
@@ -173,6 +174,25 @@ class ExampleImagesManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update path in backend settings before starting migration
|
||||||
|
try {
|
||||||
|
const pathUpdateResponse = await fetch('/api/settings', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
example_images_path: outputDir
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!pathUpdateResponse.ok) {
|
||||||
|
throw new Error(`HTTP error! Status: ${pathUpdateResponse.status}`);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to update example images path:', error);
|
||||||
|
}
|
||||||
|
|
||||||
const pattern = document.getElementById('exampleImagesMigratePattern').value || '{model}.example.{index}.{ext}';
|
const pattern = document.getElementById('exampleImagesMigratePattern').value || '{model}.example.{index}.{ext}';
|
||||||
const optimize = document.getElementById('optimizeExampleImages').checked;
|
const optimize = document.getElementById('optimizeExampleImages').checked;
|
||||||
|
|
||||||
@@ -195,6 +215,7 @@ class ExampleImagesManager {
|
|||||||
this.isDownloading = true;
|
this.isDownloading = true;
|
||||||
this.isMigrating = true;
|
this.isMigrating = true;
|
||||||
this.isPaused = false;
|
this.isPaused = false;
|
||||||
|
this.hasShownCompletionToast = false; // Reset toast flag when starting new migration
|
||||||
this.startTime = new Date();
|
this.startTime = new Date();
|
||||||
this.updateUI(data.status);
|
this.updateUI(data.status);
|
||||||
this.showProgressPanel();
|
this.showProgressPanel();
|
||||||
@@ -300,6 +321,7 @@ class ExampleImagesManager {
|
|||||||
if (data.success) {
|
if (data.success) {
|
||||||
this.isDownloading = true;
|
this.isDownloading = true;
|
||||||
this.isPaused = false;
|
this.isPaused = false;
|
||||||
|
this.hasShownCompletionToast = false; // Reset toast flag when starting new download
|
||||||
this.startTime = new Date();
|
this.startTime = new Date();
|
||||||
this.updateUI(data.status);
|
this.updateUI(data.status);
|
||||||
this.showProgressPanel();
|
this.showProgressPanel();
|
||||||
@@ -422,9 +444,11 @@ class ExampleImagesManager {
|
|||||||
clearInterval(this.progressUpdateInterval);
|
clearInterval(this.progressUpdateInterval);
|
||||||
this.progressUpdateInterval = null;
|
this.progressUpdateInterval = null;
|
||||||
|
|
||||||
if (data.status.status === 'completed') {
|
if (data.status.status === 'completed' && !this.hasShownCompletionToast) {
|
||||||
const actionType = this.isMigrating ? 'migration' : 'download';
|
const actionType = this.isMigrating ? 'migration' : 'download';
|
||||||
showToast(`Example images ${actionType} completed`, 'success');
|
showToast(`Example images ${actionType} completed`, 'success');
|
||||||
|
// Mark as shown to prevent duplicate toasts
|
||||||
|
this.hasShownCompletionToast = true;
|
||||||
// Reset migration flag
|
// Reset migration flag
|
||||||
this.isMigrating = false;
|
this.isMigrating = false;
|
||||||
// Hide the panel after a delay
|
// Hide the panel after a delay
|
||||||
|
|||||||
Reference in New Issue
Block a user