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
+1 -1
View File
@@ -97,7 +97,7 @@ export default async function postLink(
createFolder({ filePath: `archives/${newLink.collectionId}` });
archive(newLink.url, newLink.collectionId, newLink.id);
archive(newLink.id, newLink.url);
return { response: newLink, status: 200 };
}
+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 };
}
}