From 371c6317aa4371b879eae2acf44936c2f2c7e0b9 Mon Sep 17 00:00:00 2001 From: yni9ht Date: Mon, 17 Mar 2025 20:44:13 +0800 Subject: [PATCH] refactor(mount): streamline mount update logic and improve readability --- packages/server/src/services/mount.ts | 40 +++++++++++++-------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/packages/server/src/services/mount.ts b/packages/server/src/services/mount.ts index 836feacec..1fa4db1e5 100644 --- a/packages/server/src/services/mount.ts +++ b/packages/server/src/services/mount.ts @@ -123,29 +123,27 @@ export const updateMount = async ( mountId: string, mountData: Partial, ) => { - return await db.transaction(async (tx) => { - const mount = await tx - .update(mounts) - .set({ - ...mountData, - }) - .where(eq(mounts.mountId, mountId)) - .returning() - .then((value) => value[0]); + const mount = await db + .update(mounts) + .set({ + ...mountData, + }) + .where(eq(mounts.mountId, mountId)) + .returning() + .then((value) => value[0]); - if (!mount) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Mount not found", - }); - } + if (!mount) { + throw new TRPCError({ + code: "NOT_FOUND", + message: "Mount not found", + }); + } - if (mount.type === "file") { - await deleteFileMount(mountId); - await createFileMount(mountId); - } - return mount; - }); + if (mount.type === "file") { + await deleteFileMount(mountId); + await createFileMount(mountId); + } + return mount; }; export const findMountsByApplicationId = async (