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
|
* Handle progress update from WebSocket or polling
|
||||||
*/
|
*/
|
||||||
handleProgressUpdate(progress) {
|
handleProgressUpdate(progress) {
|
||||||
|
const prev = this.progress;
|
||||||
this.progress = progress;
|
this.progress = progress;
|
||||||
this.updateProgressUI(progress);
|
this.updateProgressUI(progress);
|
||||||
|
|
||||||
// Console visibility for background progress: while the modal is
|
// Only log when something actually changed (and on the first update),
|
||||||
// closed (or open), the console shows what the import is doing.
|
// so per-second polling does not spam the console with identical lines.
|
||||||
console.log(
|
const changed =
|
||||||
`[BatchImport] Progress ${Math.round(progress.progress_percent || 0)}% ` +
|
!prev ||
|
||||||
`(${progress.completed}/${progress.total}) ` +
|
prev.total !== progress.total ||
|
||||||
`status=${progress.status} ` +
|
prev.completed !== progress.completed ||
|
||||||
`success=${progress.success} failed=${progress.failed} skipped=${progress.skipped} ` +
|
prev.success !== progress.success ||
|
||||||
`item=${progress.current_item || '-'}`
|
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
|
// Check if import is complete
|
||||||
if (progress.status === 'completed' || progress.status === 'cancelled' ||
|
if (progress.status === 'completed' || progress.status === 'cancelled' ||
|
||||||
|
|||||||
@@ -192,13 +192,14 @@ describe('BatchImportManager reopen behavior (#1084)', () => {
|
|||||||
|
|
||||||
await startImportViaUrls(['https://civitai.com/images/1']);
|
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(RUNNING_PROGRESS);
|
||||||
batchImportManager.handleProgressUpdate(COMPLETED_PROGRESS);
|
batchImportManager.handleProgressUpdate(COMPLETED_PROGRESS);
|
||||||
|
|
||||||
const messages = logSpy.mock.calls.map((call) => String(call[0]));
|
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] 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);
|
expect(messages.some((m) => m.includes('[BatchImport] Import finished: status=completed'))).toBe(true);
|
||||||
|
|
||||||
logSpy.mockRestore();
|
logSpy.mockRestore();
|
||||||
|
|||||||
Reference in New Issue
Block a user