TagSpaces is an offline, open source, document manager with tagging support
add cache for aws s3 generate thumbnail
sytolkf6e410994ce0
diff --git a/src/renderer/components/dialogs/LinkGeneratorDialog.tsx b/src/renderer/components/dialogs/LinkGeneratorDialog.tsxindex db9519970..3557abeda 100644--- a/src/renderer/components/dialogs/LinkGeneratorDialog.tsx+++ b/src/renderer/components/dialogs/LinkGeneratorDialog.tsx@@ -88,13 +88,6 @@ function LinkGeneratorDialog(props: Props) {forceUpdate();return switchCurrentLocationType();});- /*} else {- signedLink.current = PlatformIO.getURLforPath(- path,- linkValidityDuration.current- );- forceUpdate();- }*/}return (diff --git a/src/renderer/components/menus/FileMenu.tsx b/src/renderer/components/menus/FileMenu.tsxindex 7d3c36b15..62a011053 100644--- a/src/renderer/components/menus/FileMenu.tsx+++ b/src/renderer/components/menus/FileMenu.tsx@@ -194,7 +194,7 @@ function FileMenu(props: Props) {onClose();let path =PlatformIO.haveObjectStoreSupport() || PlatformIO.haveWebDavSupport()- ? PlatformIO.getURLforPath(selectedFilePath)+ ? PlatformIO.generateURLforPath(selectedFilePath, 604800) // 7 days: selectedFilePath;const directoryPath = extractContainingDirectoryPath(diff --git a/src/renderer/services/meta-loader.ts b/src/renderer/services/meta-loader.tsindex 06365bec3..9f7d99dac 100644--- a/src/renderer/services/meta-loader.ts+++ b/src/renderer/services/meta-loader.ts@@ -102,7 +102,7 @@ function setThumbForEntry(thumbPath = thumbPath.substring(1);}- thumbPath = PlatformIO.getURLforPath(thumbPath, 604800);+ thumbPath = PlatformIO.generateURLforPath(thumbPath, 604800);if (thumbPath) {thumbEntry.meta = { id: getUuid(), thumbPath };}diff --git a/src/renderer/services/platform-facade.ts b/src/renderer/services/platform-facade.tsindex 4b7f7afcd..709d05b32 100644--- a/src/renderer/services/platform-facade.ts+++ b/src/renderer/services/platform-facade.ts@@ -23,6 +23,7 @@ import { Pro } from '-/pro';import { openUrlForWeb } from '-/services/utils-io';let objectStoreAPI, webDavAPI;+const urlCache = {};export default class PlatformFacade {static enableObjectStoreSupport = (objectStoreConfig: any): Promise<any> => {@@ -147,13 +148,31 @@ export default class PlatformFacade {/*** ObjectStore and webDav only+ * Function to generate or retrieve cached URL with expiration date* @param path* @param expirationInSeconds*/static getURLforPath = (path: string,- expirationInSeconds?: number,+ expirationInSeconds: number = 900,): string => {+ const currentTime = new Date().getTime();++ // Check if URL is cached and not expired+ if (urlCache[path] && urlCache[path].expirationTime > currentTime) {+ return urlCache[path].url;+ } else {+ // Generate new URL and cache it with expiration time+ const newURL = this.generateURLforPath(path, expirationInSeconds);+ urlCache[path] = {+ url: newURL,+ expirationTime: currentTime + expirationInSeconds * 1000,+ };+ return newURL;+ }+ };++ static generateURLforPath = (path, expirationInSeconds) => {if (objectStoreAPI) {const param = {path,