digital ocean spaces/aws S3 integratoin
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { prisma } from "@/lib/api/db";
|
||||
import getPermission from "@/lib/api/getPermission";
|
||||
import { Collection, UsersAndCollections } from "@prisma/client";
|
||||
import fs from "fs";
|
||||
import removeFolder from "@/lib/api/storage/removeFolder";
|
||||
|
||||
export default async function deleteCollection(
|
||||
collection: { id: number },
|
||||
@@ -56,13 +56,7 @@ export default async function deleteCollection(
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
fs.rmdirSync(`data/archives/${collectionId}`, { recursive: true });
|
||||
} catch (error) {
|
||||
console.log(
|
||||
"Collection's archive directory wasn't deleted most likely because it didn't exist..."
|
||||
);
|
||||
}
|
||||
removeFolder({ filePath: `archives/${collectionId}` });
|
||||
|
||||
return await prisma.collection.delete({
|
||||
where: {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { prisma } from "@/lib/api/db";
|
||||
import { CollectionIncludingMembersAndLinkCount } from "@/types/global";
|
||||
import { existsSync, mkdirSync } from "fs";
|
||||
import createFolder from "@/lib/api/storage/createFolder";
|
||||
|
||||
export default async function postCollection(
|
||||
collection: CollectionIncludingMembersAndLinkCount,
|
||||
@@ -66,9 +66,7 @@ export default async function postCollection(
|
||||
},
|
||||
});
|
||||
|
||||
const collectionPath = `data/archives/${newCollection.id}`;
|
||||
if (!existsSync(collectionPath))
|
||||
mkdirSync(collectionPath, { recursive: true });
|
||||
createFolder({ filePath: `archives/${newCollection.id}` });
|
||||
|
||||
return { response: newCollection, status: 200 };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user