This commit is contained in:
Daniel
2023-08-06 00:58:18 -04:00
parent 02b7a90160
commit 159075b38b
4 changed files with 54 additions and 8 deletions
+13
View File
@@ -2,6 +2,7 @@ import { prisma } from "@/lib/api/db";
import { LinkIncludingShortenedCollectionAndTags } from "@/types/global";
import { Collection, Link, UsersAndCollections } from "@prisma/client";
import getPermission from "@/lib/api/getPermission";
import moveFile from "@/lib/api/storage/moveFile";
export default async function updateLink(
link: LinkIncludingShortenedCollectionAndTags,
@@ -98,6 +99,18 @@ export default async function updateLink(
},
});
if (targetLink.collection.id !== link.collection.id) {
await moveFile(
`archives/${targetLink.collection.id}/${link.id}.pdf`,
`archives/${link.collection.id}/${link.id}.pdf`
);
await moveFile(
`archives/${targetLink.collection.id}/${link.id}.png`,
`archives/${link.collection.id}/${link.id}.png`
);
}
return { response: updatedLink, status: 200 };
}
}