1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Fixing job progress

This commit is contained in:
Patrik J. Braun 2023-04-02 12:33:44 +02:00
parent d606df9479
commit e4710da4e5
2 changed files with 25 additions and 37 deletions

View File

@ -76,53 +76,52 @@ export abstract class FileJob<S extends { indexedOnly?: boolean } = { indexedOnl
return false; return false;
} }
const processOneFile = async () => {
const filePath = this.fileQueue.shift();
try {
if ((await this.shouldProcess(filePath)) === true) {
this.Progress.Processed++;
this.Progress.log('processing: ' + filePath);
await this.processFile(filePath);
} else {
this.Progress.log('skipping: ' + filePath);
this.Progress.Skipped++;
}
} catch (e) {
console.error(e);
Logger.error(
LOG_TAG,
'Error during processing file:' + filePath + ', ' + e.toString()
);
this.Progress.log(
'Error during processing file:' + filePath + ', ' + e.toString()
);
}
};
if (!this.config.indexedOnly) { if (!this.config.indexedOnly) {
if (this.directoryQueue.length > 0) { if (this.directoryQueue.length > 0) {
await this.loadADirectoryFromDisk(); await this.loadADirectoryFromDisk();
return true
} else if (this.fileQueue.length > 0) { } else if (this.fileQueue.length > 0) {
this.Progress.Left = this.fileQueue.length; this.Progress.Left = this.fileQueue.length;
await processOneFile();
} }
} else { } else {
if (!this.DBProcessing.initiated) { if (!this.DBProcessing.initiated) {
this.Progress.log('Counting files from db'); this.Progress.log('Counting files from db');
Logger.silly(LOG_TAG, 'Counting files from db'); Logger.silly(LOG_TAG, 'Counting files from db');
this.Progress.All = await this.countMediaFromDB(); this.Progress.All = await this.countMediaFromDB();
this.Progress.log('Found:' + this.Progress.All);
Logger.silly(LOG_TAG, 'Found:' + this.Progress.All); Logger.silly(LOG_TAG, 'Found:' + this.Progress.All);
this.DBProcessing.initiated = true; this.DBProcessing.initiated = true;
return true; return true;
} }
if (this.fileQueue.length === 0) { if (this.fileQueue.length === 0) {
await this.loadMediaFilesFromDB(); await this.loadMediaFilesFromDB();
} else { return true;
this.Progress.Left = this.fileQueue.length;
await processOneFile();
} }
} }
const filePath = this.fileQueue.shift();
try {
if ((await this.shouldProcess(filePath)) === true) {
this.Progress.Processed++;
this.Progress.log('processing: ' + filePath);
await this.processFile(filePath);
} else {
this.Progress.log('skipping: ' + filePath);
this.Progress.Skipped++;
}
} catch (e) {
console.error(e);
Logger.error(
LOG_TAG,
'Error during processing file:' + filePath + ', ' + e.toString()
);
this.Progress.log(
'Error during processing file:' + filePath + ', ' + e.toString()
);
}
return true; return true;
} }

View File

@ -125,14 +125,3 @@ export class DiskManagerTH
} }
} }
export class ThumbnailTH
extends ThreadPool<void>
implements ITaskExecuter<RendererInput, void>
{
execute(input: RendererInput): Promise<void> {
return super.executeTask({
type: WorkerTaskTypes.thumbnail,
input,
} as ThumbnailTask);
}
}