diff --git a/packages/file-store/configstores/FileConfigstore.ts b/packages/file-store/configstores/FileConfigstore.ts index ef573293..e118e349 100644 --- a/packages/file-store/configstores/FileConfigstore.ts +++ b/packages/file-store/configstores/FileConfigstore.ts @@ -1,7 +1,6 @@ import fs from 'node:fs/promises' import path from 'node:path' import {Upload} from '@tus/server' -import PQueue from 'p-queue' import {Configstore} from './Types' @@ -11,16 +10,14 @@ import {Configstore} from './Types' */ export class FileConfigstore implements Configstore { directory: string - queue: PQueue constructor(path: string) { this.directory = path - this.queue = new PQueue({concurrency: 1}) } async get(key: string): Promise { try { - const buffer = await this.queue.add(() => fs.readFile(this.resolve(key), 'utf8')) + const buffer = await fs.readFile(this.resolve(key), 'utf8') return JSON.parse(buffer as string) } catch { return undefined @@ -28,23 +25,21 @@ export class FileConfigstore implements Configstore { } async set(key: string, value: Upload): Promise { - await this.queue.add(() => fs.writeFile(this.resolve(key), JSON.stringify(value))) + await fs.writeFile(this.resolve(key), JSON.stringify(value)) } async delete(key: string): Promise { - await this.queue.add(() => fs.rm(this.resolve(key))) + await fs.rm(this.resolve(key)) } async list(): Promise> { - return this.queue.add(async () => { - const files = await fs.readdir(this.directory) - const sorted = files.sort((a, b) => a.localeCompare(b)) - const name = (file: string) => path.basename(file, '.json') - // To only return tus file IDs we check if the file has a corresponding JSON info file - return sorted.filter( - (file, idx) => idx < sorted.length - 1 && name(file) === name(sorted[idx + 1]) - ) - }) + const files = await fs.readdir(this.directory) + const sorted = files.sort((a, b) => a.localeCompare(b)) + const name = (file: string) => path.basename(file, '.json') + // To only return tus file IDs we check if the file has a corresponding JSON info file + return sorted.filter( + (file, idx) => idx < sorted.length - 1 && name(file) === name(sorted[idx + 1]) + ) } private resolve(key: string): string { diff --git a/packages/file-store/package.json b/packages/file-store/package.json index 788c9c46..3b356c5d 100644 --- a/packages/file-store/package.json +++ b/packages/file-store/package.json @@ -21,8 +21,7 @@ "test": "mocha test.ts --exit --extension ts --require ts-node/register" }, "dependencies": { - "debug": "^4.3.4", - "p-queue": "^6.6.2" + "debug": "^4.3.4" }, "devDependencies": { "@tus/server": "workspace:^", diff --git a/packages/server/src/server.ts b/packages/server/src/server.ts index dd180ffd..cece359b 100644 --- a/packages/server/src/server.ts +++ b/packages/server/src/server.ts @@ -22,7 +22,6 @@ import { import type stream from 'node:stream' import type {ServerOptions, RouteHandler} from './types' import type {DataStore, Upload, CancellationContext} from './models' -import {MemoryLocker} from './lockers' type Handlers = { GET: InstanceType @@ -94,10 +93,6 @@ export class Server extends EventEmitter { throw new Error("'datastore' is not defined; must have a datastore") } - if (!options.locker) { - options.locker = new MemoryLocker() - } - const {datastore, ...rest} = options this.options = rest this.datastore = datastore diff --git a/yarn.lock b/yarn.lock index 31332497..fd8bb4bc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1500,7 +1500,6 @@ __metadata: eslint: ^8.48.0 eslint-config-custom: "workspace:*" mocha: ^10.2.0 - p-queue: ^6.6.2 should: ^13.2.3 typescript: ^5.2.2 peerDependencies: @@ -2858,13 +2857,6 @@ __metadata: languageName: node linkType: hard -"eventemitter3@npm:^4.0.4": - version: 4.0.7 - resolution: "eventemitter3@npm:4.0.7" - checksum: 1875311c42fcfe9c707b2712c32664a245629b42bb0a5a84439762dd0fd637fc54d078155ea83c2af9e0323c9ac13687e03cfba79b03af9f40c89b4960099374 - languageName: node - linkType: hard - "events@npm:^3.3.0": version: 3.3.0 resolution: "events@npm:3.3.0" @@ -4217,13 +4209,6 @@ __metadata: languageName: node linkType: hard -"p-finally@npm:^1.0.0": - version: 1.0.0 - resolution: "p-finally@npm:1.0.0" - checksum: 93a654c53dc805dd5b5891bab16eb0ea46db8f66c4bfd99336ae929323b1af2b70a8b0654f8f1eae924b2b73d037031366d645f1fd18b3d30cbd15950cc4b1d4 - languageName: node - linkType: hard - "p-limit@npm:^3.0.1, p-limit@npm:^3.0.2": version: 3.1.0 resolution: "p-limit@npm:3.1.0" @@ -4251,25 +4236,6 @@ __metadata: languageName: node linkType: hard -"p-queue@npm:^6.6.2": - version: 6.6.2 - resolution: "p-queue@npm:6.6.2" - dependencies: - eventemitter3: ^4.0.4 - p-timeout: ^3.2.0 - checksum: 832642fcc4ab6477b43e6d7c30209ab10952969ed211c6d6f2931be8a4f9935e3578c72e8cce053dc34f2eb6941a408a2c516a54904e989851a1a209cf19761c - languageName: node - linkType: hard - -"p-timeout@npm:^3.2.0": - version: 3.2.0 - resolution: "p-timeout@npm:3.2.0" - dependencies: - p-finally: ^1.0.0 - checksum: 3dd0eaa048780a6f23e5855df3dd45c7beacff1f820476c1d0d1bcd6648e3298752ba2c877aa1c92f6453c7dd23faaf13d9f5149fc14c0598a142e2c5e8d649c - languageName: node - linkType: hard - "parent-module@npm:^1.0.0": version: 1.0.1 resolution: "parent-module@npm:1.0.1"