From d940b4fa85ea2facb1c9d495d290bfd0de235047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9e=20Kooi?= Date: Thu, 28 Sep 2017 12:33:39 +0200 Subject: [PATCH] restore: Add `indexedDB.expires` option to configure expiry time. --- src/plugins/RestoreFiles/IndexedDBStore.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/RestoreFiles/IndexedDBStore.js b/src/plugins/RestoreFiles/IndexedDBStore.js index 5ac964b2b..6fa40f133 100644 --- a/src/plugins/RestoreFiles/IndexedDBStore.js +++ b/src/plugins/RestoreFiles/IndexedDBStore.js @@ -5,7 +5,7 @@ const isSupported = !!indexedDB const DB_NAME = 'uppy-blobs' const STORE_NAME = 'files' // maybe have a thumbnail store in the future -const DEFAULT_EXPIRY = 24 * 60 * 60 * 1000 // 1 day +const DEFAULT_EXPIRY = 24 * 60 * 60 * 1000 // 24 hours const DB_VERSION = 3 // Set default `expires` dates on existing stored blobs. @@ -66,6 +66,7 @@ class IndexedDBStore { this.opts = Object.assign({ dbName: DB_NAME, storeName: 'default', + expires: DEFAULT_EXPIRY, // 24 hours maxFileSize: 10 * 1024 * 1024, // 10 MB maxTotalSize: 300 * 1024 * 1024 // 300 MB }, opts) @@ -170,7 +171,7 @@ class IndexedDBStore { id: this.key(file.id), fileID: file.id, store: this.name, - expires: Date.now() + DEFAULT_EXPIRY, + expires: Date.now() + this.opts.expires, data: file.data }) return waitForRequest(request)