mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-08-28 00:11:27 -03:00
fix(recipes): log batch import progress only when it changes (#1084)
This commit is contained in:
@@ -423,18 +423,31 @@ export class BatchImportManager {
|
||||
* Handle progress update from WebSocket or polling
|
||||
*/
|
||||
handleProgressUpdate(progress) {
|
||||
const prev = this.progress;
|
||||
this.progress = progress;
|
||||
this.updateProgressUI(progress);
|
||||
|
||||
// Console visibility for background progress: while the modal is
|
||||
// closed (or open), the console shows what the import is doing.
|
||||
console.log(
|
||||
`[BatchImport] Progress ${Math.round(progress.progress_percent || 0)}% ` +
|
||||
`(${progress.completed}/${progress.total}) ` +
|
||||
`status=${progress.status} ` +
|
||||
`success=${progress.success} failed=${progress.failed} skipped=${progress.skipped} ` +
|
||||
`item=${progress.current_item || '-'}`
|
||||
);
|
||||
// Only log when something actually changed (and on the first update),
|
||||
// so per-second polling does not spam the console with identical lines.
|
||||
const changed =
|
||||
!prev ||
|
||||
prev.total !== progress.total ||
|
||||
prev.completed !== progress.completed ||
|
||||
prev.success !== progress.success ||
|
||||
prev.failed !== progress.failed ||
|
||||
prev.skipped !== progress.skipped ||
|
||||
prev.status !== progress.status ||
|
||||
prev.current_item !== progress.current_item;
|
||||
|
||||
if (changed) {
|
||||
console.log(
|
||||
`[BatchImport] Progress ${Math.round(progress.progress_percent || 0)}% ` +
|
||||
`(${progress.completed}/${progress.total}) ` +
|
||||
`status=${progress.status} ` +
|
||||
`success=${progress.success} failed=${progress.failed} skipped=${progress.skipped} ` +
|
||||
`item=${progress.current_item || '-'}`
|
||||
);
|
||||
}
|
||||
|
||||
// Check if import is complete
|
||||
if (progress.status === 'completed' || progress.status === 'cancelled' ||
|
||||
|
||||
@@ -192,13 +192,14 @@ describe('BatchImportManager reopen behavior (#1084)', () => {
|
||||
|
||||
await startImportViaUrls(['https://civitai.com/images/1']);
|
||||
|
||||
// force a polled progress update
|
||||
batchImportManager.handleProgressUpdate(RUNNING_PROGRESS);
|
||||
// A second poll tick with identical data must not log again (#1084).
|
||||
batchImportManager.handleProgressUpdate(RUNNING_PROGRESS);
|
||||
batchImportManager.handleProgressUpdate(COMPLETED_PROGRESS);
|
||||
|
||||
const messages = logSpy.mock.calls.map((call) => String(call[0]));
|
||||
expect(messages.some((m) => m.includes('[BatchImport] Import started, operation_id=op-123'))).toBe(true);
|
||||
expect(messages.some((m) => m.includes('[BatchImport] Progress 50%'))).toBe(true);
|
||||
expect(messages.filter((m) => m.includes('[BatchImport] Progress 50%')).length).toBe(1);
|
||||
expect(messages.some((m) => m.includes('[BatchImport] Import finished: status=completed'))).toBe(true);
|
||||
|
||||
logSpy.mockRestore();
|
||||
|
||||
Reference in New Issue
Block a user