@abraca/dabra 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7579,6 +7579,48 @@ var FileBlobStore = class FileBlobStore extends EventEmitter {
|
|
|
7579
7579
|
const tx = db.transaction("blobs", "readonly");
|
|
7580
7580
|
return (await txPromise(tx.objectStore("blobs"), tx.objectStore("blobs").get(key)))?.blob ?? null;
|
|
7581
7581
|
}
|
|
7582
|
+
/** Return metadata for all cached blobs (for storage stats). */
|
|
7583
|
+
async getAllCachedEntries() {
|
|
7584
|
+
const db = await this.getDb();
|
|
7585
|
+
if (!db) return [];
|
|
7586
|
+
return new Promise((resolve, reject) => {
|
|
7587
|
+
const tx = db.transaction("blobs", "readonly");
|
|
7588
|
+
const store = tx.objectStore("blobs");
|
|
7589
|
+
const keysReq = store.getAllKeys();
|
|
7590
|
+
const valuesReq = store.getAll();
|
|
7591
|
+
tx.oncomplete = () => {
|
|
7592
|
+
const keys = keysReq.result;
|
|
7593
|
+
const values = valuesReq.result;
|
|
7594
|
+
resolve(keys.map((key, i) => {
|
|
7595
|
+
const slashIdx = key.indexOf("/");
|
|
7596
|
+
const docId = key.slice(0, slashIdx);
|
|
7597
|
+
const uploadId = key.slice(slashIdx + 1);
|
|
7598
|
+
const e = values[i];
|
|
7599
|
+
return {
|
|
7600
|
+
docId,
|
|
7601
|
+
uploadId,
|
|
7602
|
+
filename: e.filename,
|
|
7603
|
+
mimeType: e.mime_type,
|
|
7604
|
+
size: e.blob.size,
|
|
7605
|
+
cachedAt: e.cachedAt
|
|
7606
|
+
};
|
|
7607
|
+
}));
|
|
7608
|
+
};
|
|
7609
|
+
tx.onerror = () => reject(tx.error);
|
|
7610
|
+
});
|
|
7611
|
+
}
|
|
7612
|
+
/** Revoke all object URLs and clear the entire blob cache from IDB. */
|
|
7613
|
+
async clearAllBlobs() {
|
|
7614
|
+
for (const url of this.objectUrls.values()) URL.revokeObjectURL(url);
|
|
7615
|
+
this.objectUrls.clear();
|
|
7616
|
+
const db = await this.getDb();
|
|
7617
|
+
if (!db) return;
|
|
7618
|
+
return new Promise((resolve, reject) => {
|
|
7619
|
+
const req = db.transaction("blobs", "readwrite").objectStore("blobs").clear();
|
|
7620
|
+
req.onsuccess = () => resolve();
|
|
7621
|
+
req.onerror = () => reject(req.error);
|
|
7622
|
+
});
|
|
7623
|
+
}
|
|
7582
7624
|
/** Revoke the object URL and remove the blob from cache. */
|
|
7583
7625
|
async evictBlob(docId, uploadId) {
|
|
7584
7626
|
const key = this.blobKey(docId, uploadId);
|