@tus/file-store
Advanced tools
Comparing version 1.0.1 to 1.1.0
import { Upload } from '@tus/server'; | ||
import PQueue from 'p-queue'; | ||
import { Configstore } from './Types'; | ||
@@ -10,3 +9,2 @@ /** | ||
directory: string; | ||
queue: PQueue; | ||
constructor(path: string); | ||
@@ -13,0 +11,0 @@ get(key: string): Promise<Upload | undefined>; |
@@ -9,3 +9,2 @@ "use strict"; | ||
const node_path_1 = __importDefault(require("node:path")); | ||
const p_queue_1 = __importDefault(require("p-queue")); | ||
/** | ||
@@ -18,7 +17,6 @@ * FileConfigstore writes the `Upload` JSON metadata to disk next the uploaded file itself. | ||
this.directory = path; | ||
this.queue = new p_queue_1.default({ concurrency: 1 }); | ||
} | ||
async get(key) { | ||
try { | ||
const buffer = await this.queue.add(() => promises_1.default.readFile(this.resolve(key), 'utf8')); | ||
const buffer = await promises_1.default.readFile(this.resolve(key), 'utf8'); | ||
return JSON.parse(buffer); | ||
@@ -31,15 +29,13 @@ } | ||
async set(key, value) { | ||
await this.queue.add(() => promises_1.default.writeFile(this.resolve(key), JSON.stringify(value))); | ||
await promises_1.default.writeFile(this.resolve(key), JSON.stringify(value)); | ||
} | ||
async delete(key) { | ||
await this.queue.add(() => promises_1.default.rm(this.resolve(key))); | ||
await promises_1.default.rm(this.resolve(key)); | ||
} | ||
async list() { | ||
return this.queue.add(async () => { | ||
const files = await promises_1.default.readdir(this.directory); | ||
const sorted = files.sort((a, b) => a.localeCompare(b)); | ||
const name = (file) => node_path_1.default.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 promises_1.default.readdir(this.directory); | ||
const sorted = files.sort((a, b) => a.localeCompare(b)); | ||
const name = (file) => node_path_1.default.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])); | ||
} | ||
@@ -46,0 +42,0 @@ resolve(key) { |
{ | ||
"$schema": "https://json.schemastore.org/package.json", | ||
"name": "@tus/file-store", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Local file storage for @tus/server", | ||
@@ -24,7 +24,6 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"debug": "^4.3.4", | ||
"p-queue": "^6.6.2" | ||
"debug": "^4.3.4" | ||
}, | ||
"devDependencies": { | ||
"@tus/server": "^1.0.0", | ||
"@tus/server": "^1.0.1", | ||
"@types/debug": "^4.1.8", | ||
@@ -40,3 +39,3 @@ "@types/mocha": "^10.0.1", | ||
"peerDependencies": { | ||
"@tus/server": "^1.0.0" | ||
"@tus/server": "^1.0.1" | ||
}, | ||
@@ -43,0 +42,0 @@ "optionalDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3
23119
422
- Removedp-queue@^6.6.2
- Removedeventemitter3@4.0.7(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedp-queue@6.6.2(transitive)
- Removedp-timeout@3.2.0(transitive)