mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor(mount): streamline mount update logic and improve readability
This commit is contained in:
parent
7c17cfb5c7
commit
371c6317aa
@ -123,29 +123,27 @@ export const updateMount = async (
|
|||||||
mountId: string,
|
mountId: string,
|
||||||
mountData: Partial<Mount>,
|
mountData: Partial<Mount>,
|
||||||
) => {
|
) => {
|
||||||
return await db.transaction(async (tx) => {
|
const mount = await db
|
||||||
const mount = await tx
|
.update(mounts)
|
||||||
.update(mounts)
|
.set({
|
||||||
.set({
|
...mountData,
|
||||||
...mountData,
|
})
|
||||||
})
|
.where(eq(mounts.mountId, mountId))
|
||||||
.where(eq(mounts.mountId, mountId))
|
.returning()
|
||||||
.returning()
|
.then((value) => value[0]);
|
||||||
.then((value) => value[0]);
|
|
||||||
|
|
||||||
if (!mount) {
|
if (!mount) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "NOT_FOUND",
|
code: "NOT_FOUND",
|
||||||
message: "Mount not found",
|
message: "Mount not found",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mount.type === "file") {
|
if (mount.type === "file") {
|
||||||
await deleteFileMount(mountId);
|
await deleteFileMount(mountId);
|
||||||
await createFileMount(mountId);
|
await createFileMount(mountId);
|
||||||
}
|
}
|
||||||
return mount;
|
return mount;
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const findMountsByApplicationId = async (
|
export const findMountsByApplicationId = async (
|
||||||
|
Loading…
Reference in New Issue
Block a user