mirror of
https://github.com/wukko/cobalt.git
synced 2025-05-29 13:00:12 +02:00
web/opfs: capitalize processing dir constant
This commit is contained in:
parent
a22e4c3cf9
commit
54ec1645fe
@ -1,4 +1,5 @@
|
|||||||
const cobaltProcessingDir = "cobalt-processing-data";
|
|
||||||
|
const COBALT_PROCESSING_DIR = "cobalt-processing-data";
|
||||||
|
|
||||||
export class OPFSStorage {
|
export class OPFSStorage {
|
||||||
#root;
|
#root;
|
||||||
@ -13,7 +14,7 @@ export class OPFSStorage {
|
|||||||
|
|
||||||
static async init() {
|
static async init() {
|
||||||
const root = await navigator.storage.getDirectory();
|
const root = await navigator.storage.getDirectory();
|
||||||
const cobaltDir = await root.getDirectoryHandle(cobaltProcessingDir, { create: true });
|
const cobaltDir = await root.getDirectoryHandle(COBALT_PROCESSING_DIR, { create: true });
|
||||||
const handle = await cobaltDir.getFileHandle(crypto.randomUUID(), { create: true });
|
const handle = await cobaltDir.getFileHandle(crypto.randomUUID(), { create: true });
|
||||||
const reader = await handle.createSyncAccessHandle();
|
const reader = await handle.createSyncAccessHandle();
|
||||||
|
|
||||||
@ -49,7 +50,7 @@ export class OPFSStorage {
|
|||||||
|
|
||||||
export const removeFromFileStorage = async (filename: string) => {
|
export const removeFromFileStorage = async (filename: string) => {
|
||||||
const root = await navigator.storage.getDirectory();
|
const root = await navigator.storage.getDirectory();
|
||||||
const cobaltDir = await root.getDirectoryHandle(cobaltProcessingDir);
|
const cobaltDir = await root.getDirectoryHandle(COBALT_PROCESSING_DIR);
|
||||||
return await cobaltDir.removeEntry(filename);
|
return await cobaltDir.removeEntry(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ export const clearFileStorage = async () => {
|
|||||||
if (navigator.storage.getDirectory) {
|
if (navigator.storage.getDirectory) {
|
||||||
const root = await navigator.storage.getDirectory();
|
const root = await navigator.storage.getDirectory();
|
||||||
try {
|
try {
|
||||||
await root.removeEntry(cobaltProcessingDir, { recursive: true });
|
await root.removeEntry(COBALT_PROCESSING_DIR, { recursive: true });
|
||||||
} catch {
|
} catch {
|
||||||
// ignore the error because the dir might be missing and that's okay!
|
// ignore the error because the dir might be missing and that's okay!
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user