Skip to content

Commit

Permalink
chore: update polling example
Browse files Browse the repository at this point in the history
  • Loading branch information
kukhariev committed Dec 19, 2024
1 parent 813dece commit 672fe33
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions examples/express-polling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ const onComplete: express.RequestHandler = (req, res) => {
const moving = (processes[file.name] ??= {} as Moving);
if (!moving.status) {
moving.status = 'moving';
const source = storage.getFilePath(file.name);
const destination = path.resolve(moveTo, file.originalName);
void (async () => {
try {
const source = storage.getFilePath(file.name);
const destination = path.resolve(moveTo, file.originalName);
if (!destination.startsWith(path.resolve(moveTo))) {
throw new Error(`Invalid destination path: ${destination}`);
}
await copyFile(source, destination);
await storage.delete(file);
moving.status = 'done';
Expand Down

0 comments on commit 672fe33

Please sign in to comment.