From b07040a26f9ddf6db84b81cd15eb58a54cb53f7b Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 18 Jul 2023 11:59:57 -0400 Subject: [PATCH] small improvements --- components/Modal/Link/LinkDetails.tsx | 2 +- lib/api/controllers/links/postLink.ts | 5 ++++- lib/api/storage/createFolder.ts | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/components/Modal/Link/LinkDetails.tsx b/components/Modal/Link/LinkDetails.tsx index c374aec..3d18233 100644 --- a/components/Modal/Link/LinkDetails.tsx +++ b/components/Modal/Link/LinkDetails.tsx @@ -131,7 +131,7 @@ export default function LinkDetails({ link }: Props) { height={42} alt="" id={"favicon-" + link.id} - className="select-none mt-2 rounded-full shadow border-[3px] border-white bg-white aspect-square" + className="select-none mt-2 rounded-md shadow border-[3px] border-white bg-white aspect-square" draggable="false" onLoad={(e) => { try { diff --git a/lib/api/controllers/links/postLink.ts b/lib/api/controllers/links/postLink.ts index 940e318..ed04a89 100644 --- a/lib/api/controllers/links/postLink.ts +++ b/lib/api/controllers/links/postLink.ts @@ -4,6 +4,7 @@ import getTitle from "@/lib/api/getTitle"; import archive from "@/lib/api/archive"; import { Collection, Link, UsersAndCollections } from "@prisma/client"; import getPermission from "@/lib/api/getPermission"; +import createFolder from "@/lib/api/storage/createFolder"; export default async function postLink( link: LinkIncludingShortenedCollectionAndTags, @@ -14,7 +15,7 @@ export default async function postLink( if (!link.name) { return { response: "Please enter a valid name for the link.", status: 400 }; } else if (!link.collection.name) { - return { response: "Please enter a valid collection.", status: 400 }; + link.collection.name = "Other"; } if (link.collection.id) { @@ -83,6 +84,8 @@ export default async function postLink( include: { tags: true, collection: true }, }); + createFolder({ filePath: `archives/${newLink.collectionId}` }); + archive(newLink.url, newLink.collectionId, newLink.id); return { response: newLink, status: 200 }; diff --git a/lib/api/storage/createFolder.ts b/lib/api/storage/createFolder.ts index 18fc0d7..7c2f0b0 100644 --- a/lib/api/storage/createFolder.ts +++ b/lib/api/storage/createFolder.ts @@ -4,7 +4,7 @@ import s3Client from "./s3Client"; export default function createFolder({ filePath }: { filePath: string }) { if (s3Client) { - // Do nothing, S3 builds files recursively + // Do nothing, S3 creates directories recursively } else { const storagePath = process.env.STORAGE_FOLDER; const creationPath = path.join(process.cwd(), storagePath + "/" + filePath);