Skip to content

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

fix thumbsGeneration

Stanimir2976b4a4770f
diff --git a/app/hooks/ThumbGenerationContextProvider.tsx b/app/hooks/ThumbGenerationContextProvider.tsx
index c45b695fa..3785e2c41 100644
--- a/app/hooks/ThumbGenerationContextProvider.tsx
+++ b/app/hooks/ThumbGenerationContextProvider.tsx
@@ -107,8 +107,7 @@ export const ThumbGenerationContextProvider = ({
// initial thumbnail generation without .ts folder
loadCurrentDirMeta(
currentDirectoryPath,
- currentDirectoryEntries,
- pageFiles
+ currentDirectoryEntries
).then(entries => updateCurrentDirEntries(entries));
/*PlatformIO.listMetaDirectoryPromise(currentDirectoryPath)
.then(meta => {
@@ -212,20 +211,33 @@ export const ThumbGenerationContextProvider = ({
return true;
});
}
+ setGenThumbs(false);
return Promise.resolve(false);
}
function thumbnailMainGeneration(mainEntries: string[]): Promise<boolean> {
- return Promise.all(
- mainEntries.map(tmbPath => getThumbnailURLPromise(tmbPath))
- )
- .then(() => {
- return true;
- })
- .catch(e => {
- console.log('thumbnailMainGeneration', e);
- return false;
- });
+ const maxExecutionTime = 5000;
+ const timeoutPromise = new Promise((resolve, reject) => {
+ setTimeout(() => {
+ reject(
+ new Error('Maximum execution time exceeded:' + maxExecutionTime)
+ );
+ }, maxExecutionTime);
+ });
+ const promises = mainEntries.map(tmbPath =>
+ getThumbnailURLPromise(tmbPath)
+ );
+ return (
+ Promise.race([Promise.allSettled(promises), timeoutPromise])
+ //return Promise.allSettled(promises)
+ .then(() => {
+ return true;
+ })
+ .catch(e => {
+ console.log('thumbnailMainGeneration', e);
+ return false;
+ })
+ );
}
const context = useMemo(() => {
diff --git a/package-lock.json b/package-lock.json
index 9b5341075..e6cb7f156 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -42488,6 +42488,7 @@
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.3.tgz",
"integrity": "sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ==",
+ "peer": true,
"dependencies": {
"graceful-fs": "^4.1.11",
"imurmurhash": "^0.1.4",
@@ -75312,6 +75313,7 @@
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.3.tgz",
"integrity": "sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ==",
+ "peer": true,
"requires": {
"graceful-fs": "^4.1.11",
"imurmurhash": "^0.1.4",