TagSpaces is an offline, open source, document manager with tagging support
fix Use as background from context menu do not work on S3
sytolk1ee4432d0c40
diff --git a/package-lock.json b/package-lock.jsonindex d0932b59f..0d49ddd14 100644--- a/package-lock.json+++ b/package-lock.json@@ -196,7 +196,7 @@"yarn": "please-use-npm"},"optionalDependencies": {- "@tagspacespro/tagspacespro": "5.0.17"+ "@tagspacespro/tagspacespro": "5.0.18"}},"node_modules/@aashutoshrathi/word-wrap": {@@ -13571,9 +13571,9 @@}},"node_modules/@tagspacespro/tagspacespro": {- "version": "5.0.17",- "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.17/3799dc363cf4df247fe03eb8d2d023ee2ed622c6",- "integrity": "sha512-UXfw0YmHg+7xWhUhodrNN5+QrzpaiLXYYzWNbvOJtDThcjkagoQqVK3dmiYTMX77/HumqNpAFqGFkVLcmjsVWQ==",+ "version": "5.0.18",+ "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.18/4154c247c3738445e0763b1cdfbb8cda46a843ca",+ "integrity": "sha512-3+7S+f8VRk9twTLE50icZanVayskc6XjYD9vORaethIfc/kVZJstSnVrkntssVdFyJkaG9INQMB5CYAeGaHoVg==","license": "Proprietary","optional": true},@@ -54692,9 +54692,9 @@}},"@tagspacespro/tagspacespro": {- "version": "5.0.17",- "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.17/3799dc363cf4df247fe03eb8d2d023ee2ed622c6",- "integrity": "sha512-UXfw0YmHg+7xWhUhodrNN5+QrzpaiLXYYzWNbvOJtDThcjkagoQqVK3dmiYTMX77/HumqNpAFqGFkVLcmjsVWQ==",+ "version": "5.0.18",+ "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.18/4154c247c3738445e0763b1cdfbb8cda46a843ca",+ "integrity": "sha512-3+7S+f8VRk9twTLE50icZanVayskc6XjYD9vORaethIfc/kVZJstSnVrkntssVdFyJkaG9INQMB5CYAeGaHoVg==","optional": true},"@teamsupercell/typings-for-css-modules-loader": {diff --git a/src/renderer/hooks/EditedEntryMetaContextProvider.tsx b/src/renderer/hooks/EditedEntryMetaContextProvider.tsxindex 8dd546677..68cf31c90 100644--- a/src/renderer/hooks/EditedEntryMetaContextProvider.tsx+++ b/src/renderer/hooks/EditedEntryMetaContextProvider.tsx@@ -17,9 +17,11 @@*/import React, { createContext, useMemo, useReducer, useRef } from 'react';+import { getBgndFileLocationForDirectory } from '@tagspaces/tagspaces-common/paths';import { TS } from '-/tagspaces.namespace';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { saveFsEntryMeta } from '-/utils/metaoperations';+import PlatformIO from '-/services/platform-facade';type EditedEntryMetaContextData = {metaActions: TS.EditMetaAction[];@@ -151,6 +153,14 @@ export const EditedEntryMetaContextProvider = ({}function setBackgroundImageChange(entry: TS.FileSystemEntry) {+ if (PlatformIO.haveObjectStoreSupport() || PlatformIO.haveWebDavSupport()) {+ // reload cache+ const folderBgndPath = getBgndFileLocationForDirectory(+ entry.path,+ PlatformIO.getDirSeparator(),+ );+ PlatformIO.generateURLforPath(folderBgndPath, 604800);+ }const action: TS.EditMetaAction = {action: 'bgdImgChange',entry: {diff --git a/src/renderer/services/platform-facade.ts b/src/renderer/services/platform-facade.tsindex 709d05b32..e1800b497 100644--- a/src/renderer/services/platform-facade.ts+++ b/src/renderer/services/platform-facade.ts@@ -163,26 +163,28 @@ export default class PlatformFacade {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;+ return this.generateURLforPath(path, expirationInSeconds);}};static generateURLforPath = (path, expirationInSeconds) => {+ let url;if (objectStoreAPI) {const param = {path,bucketName: objectStoreAPI.config().bucketName,};- return objectStoreAPI.getURLforPath(param, expirationInSeconds);+ url = objectStoreAPI.getURLforPath(param, expirationInSeconds);} else if (webDavAPI) {- return webDavAPI.getURLforPath(path);+ url = webDavAPI.getURLforPath(path);+ }+ if (url) {+ urlCache[path] = {+ url: url,+ expirationTime: new Date().getTime() + expirationInSeconds * 1000,+ };}- return undefined;+ return url;};/**diff --git a/src/renderer/services/thumbsgenerator.ts b/src/renderer/services/thumbsgenerator.tsindex b3029ae18..26cb4379c 100644--- a/src/renderer/services/thumbsgenerator.ts+++ b/src/renderer/services/thumbsgenerator.ts@@ -449,6 +449,9 @@ export function generateImageThumbnail(maxTmbSize?: number,): Promise<string> {try {+ if (fileURL.startsWith('http://') || fileURL.startsWith('https://')) {+ return getResizedImageThumbnail(fileURL, maxTmbSize);+ }return PlatformIO.getFileContentPromise(fileURL, 'arraybuffer').then((content) => {const ext = extractFileExtension(