diff --git a/client/helpers/cache.js b/client/helpers/cache.js index aec3a568..1c2f6055 100644 --- a/client/helpers/cache.js +++ b/client/helpers/cache.js @@ -1,6 +1,5 @@ import { setup_cache_state } from "."; import { currentBackend, currentShare } from "./cache_state.js"; -import Path from "path"; const DB_VERSION = 4; const FILE_PATH = "file_path"; @@ -333,21 +332,28 @@ export function setup_cache() { cache = new DataFromMemory(); if ("indexedDB" in window && window.indexedDB !== null) { cache = new DataFromIndexedDB(); - const currentPath = location.pathname.replace(/^\/.*?\//, "/"); return Promise.all([cache.db, setup_cache_state()]) - .then(() => cache.update(FILE_PATH, [currentBackend(), currentShare(), currentPath], (response) => { - response.results = response.results.reduce((acc, file) => { - if (file.icon === "loading") { - cache.remove(FILE_PATH, [currentBackend(), currentShare(), Path.join(currentPath, "../")], false); - cache.remove(FILE_CONTENT, [currentBackend(), currentShare(), Path.join(currentPath, "../")], false); - cache.remove(FILE_TAG, [currentBackend(), currentShare(), Path.join(currentPath, "../")], false); - return acc; + .then(() => { + const currentPath = decodeURIComponent(location.pathname.replace(/^\/.*?\//, "/")); + return cache.get( + FILE_PATH, + [currentBackend(), currentShare(), currentPath], + ).then((response) => { + if (!response || !response.results) return; + for (let i=0; i { if (err === "INDEXEDDB_NOT_SUPPORTED") { // Firefox in private mode act like if it supports indexedDB but