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

improving temp folder cleaning

This commit is contained in:
Patrik J. Braun 2020-01-01 00:06:43 +01:00
parent 500253148a
commit ecd51ec9a5

View File

@ -60,6 +60,7 @@ export class TempFolderCleaningJob extends Job {
const validFiles = [ProjectPath.TranscodedFolder, ProjectPath.FacesFolder]; const validFiles = [ProjectPath.TranscodedFolder, ProjectPath.FacesFolder];
for (let i = 0; i < files.length; ++i) { for (let i = 0; i < files.length; ++i) {
if (validFiles.indexOf(files[i]) === -1) { if (validFiles.indexOf(files[i]) === -1) {
this.Progress.log('processing: ' + files[i]);
this.Progress.Processed++; this.Progress.Processed++;
if ((await fsp.stat(files[i])).isDirectory()) { if ((await fsp.stat(files[i])).isDirectory()) {
await rimrafPR(files[i]); await rimrafPR(files[i]);
@ -67,12 +68,12 @@ export class TempFolderCleaningJob extends Job {
await fsp.unlink(files[i]); await fsp.unlink(files[i]);
} }
} else { } else {
this.Progress.log('skipping: ' + files[i]);
this.Progress.Skipped++; this.Progress.Skipped++;
} }
} }
this.Progress.log('processing: ' + ProjectPath.TempFolder);
return true; return true;
@ -85,19 +86,26 @@ export class TempFolderCleaningJob extends Job {
const stat = await fsp.stat(filePath); const stat = await fsp.stat(filePath);
this.Progress.Left = this.directoryQueue.length; this.Progress.Left = this.directoryQueue.length;
this.Progress.log('processing: ' + filePath);
if (stat.isDirectory()) { if (stat.isDirectory()) {
if (await this.isValidDirectory(filePath) === false) { if (await this.isValidDirectory(filePath) === false) {
this.Progress.log('processing: ' + filePath);
this.Progress.Processed++; this.Progress.Processed++;
await rimrafPR(filePath); await rimrafPR(filePath);
} else { } else {
this.Progress.log('skipping: ' + filePath);
this.Progress.Skipped++; this.Progress.Skipped++;
this.directoryQueue = this.directoryQueue.concat(await this.readDir(filePath)); this.directoryQueue = this.directoryQueue.concat(await this.readDir(filePath));
} }
} else { } else {
if (await this.isValidFile(filePath) === false) { if (await this.isValidFile(filePath) === false) {
this.Progress.log('processing: ' + filePath);
this.Progress.Processed++;
await fsp.unlink(filePath); await fsp.unlink(filePath);
} else {
this.Progress.log('skipping: ' + filePath);
this.Progress.Skipped++;
} }
} }
return true; return true;
} }