Skip to content

TagSpaces is an offline, open source, document manager with tagging support

let the worker generate only one batch of thumbs at once

Ilian Sapundshievcd907a093cb3
diff --git a/app/splash-worker.js b/app/splash-worker.js
index 5ba756496..431d22cb5 100644
--- a/app/splash-worker.js
+++ b/app/splash-worker.js
@@ -22,6 +22,8 @@ import { walkDirectory, enhanceEntry } from './services/utils-io';
import AppConfig from './config';
import { getThumbnailURLPromise } from './services/thumbsgenerator';
+let isGeneratingThumbs = false;
+
function init() {
console.log('Init worker');
ipcRenderer.on('worker', (event, arg) => {
@@ -70,15 +72,16 @@ function init() {
}
case 'createThumbnails': {
console.log('createThumbnails started in worker window');
- if (!arg.tmbGenerationList || arg.tmbGenerationList.length < 1) {
+ if (!arg.tmbGenerationList || arg.tmbGenerationList.length < 1 || isGeneratingThumbs) {
ipcRenderer.send('worker', {
id: arg.id,
action: arg.action,
result: [],
- error: 'Empty or not available tmb list'
+ error: 'Empty or not available tmb list or busy worker'
});
break;
}
+ isGeneratingThumbs = true;
const tmbGenerationPromises = [];
arg.tmbGenerationList.map(entry => tmbGenerationPromises.push(getThumbnailURLPromise(entry)));
Promise.all(tmbGenerationPromises).then(tmbResult => {
@@ -89,6 +92,7 @@ function init() {
result: tmbResult,
error: ''
});
+ isGeneratingThumbs = false;
return true;
}).catch(error => {
console.warn('Tmb gener: ' + error);
@@ -98,6 +102,7 @@ function init() {
result: [],
error: 'Error generating tmbs: ' + error
});
+ isGeneratingThumbs = false;
});
break;
}