Skip to content

Open-source and local-first Slack and Notion alternative that puts you in control of your data

Add tryDeleteFile utility for safe file deletion in file-upload-tus.ts (#290)

Hakan Shehu173c6358c579
diff --git a/apps/server/src/api/client/routes/workspaces/files/file-upload-tus.ts b/apps/server/src/api/client/routes/workspaces/files/file-upload-tus.ts
index b8c146bf..37cbd51a 100644
--- a/apps/server/src/api/client/routes/workspaces/files/file-upload-tus.ts
+++ b/apps/server/src/api/client/routes/workspaces/files/file-upload-tus.ts
@@ -17,7 +17,13 @@ import { mapNode, updateNode } from '@colanode/server/lib/nodes';
import { storage } from '@colanode/server/lib/storage';
import { RedisLocker } from '@colanode/server/lib/storage/tus/redis-locker';
-const tusStore = storage.tusStore;
+const tryDeleteFile = async (path: string): Promise<void> => {
+ try {
+ await storage.delete(path);
+ } catch {
+ // Best effort cleanup - ignore errors if file doesn't exist or can't be deleted
+ }
+};
export const fileUploadTusRoute: FastifyPluginCallbackZod = (
instance,
@@ -85,7 +91,7 @@ export const fileUploadTusRoute: FastifyPluginCallbackZod = (
const tusServer = new Server({
path: '/tus',
- datastore: tusStore,
+ datastore: storage.tusStore,
locker:
config.storage.tus.locker.type === 'redis'
? new RedisLocker(redis, config.storage.tus.locker.prefix)
@@ -218,7 +224,7 @@ export const fileUploadTusRoute: FastifyPluginCallbackZod = (
}
const tusInfoPath = `${path}.info`;
- await storage.delete(tusInfoPath);
+ await tryDeleteFile(tusInfoPath);
return {
status_code: 200,