feat: removeData

This commit is contained in:
cha0s 2024-06-29 09:52:23 -05:00
parent b3087ac4d3
commit bcbef693cc
2 changed files with 8 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import {get, set} from 'idb-keyval';
import {del, get, set} from 'idb-keyval';
import {encode} from '@/packets/index.js';
@ -27,6 +27,9 @@ class WorkerServer extends Server {
error.code = 'ENOENT';
throw error;
}
async removeData(path) {
await del(this.constructor.qualify(path));
}
async writeData(path, view) {
await set(this.constructor.qualify(path), view);
}

View File

@ -1,4 +1,4 @@
import {mkdir, readFile, writeFile} from 'node:fs/promises';
import {mkdir, readFile, unlink, writeFile} from 'node:fs/promises';
import {dirname, join} from 'node:path';
import {WebSocketServer} from 'ws';
@ -64,6 +64,9 @@ class SocketServer extends Server {
await this.ensurePath(dirname(qualified));
return readFile(qualified);
}
async removeData(path) {
await unlink(path);
}
async writeData(path, view) {
const qualified = this.constructor.qualify(path);
await this.ensurePath(dirname(qualified));