diff --git a/apps/backend/src/app/files/files.service.spec.ts b/apps/backend/src/app/files/files.service.spec.ts deleted file mode 100644 index 38817b2..0000000 --- a/apps/backend/src/app/files/files.service.spec.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Test, TestingModule } from "@nestjs/testing"; -import { FilesService } from "./files.service"; - -describe("FilesService", () => { - let service: FilesService; - - beforeEach(async () => { - const module: TestingModule = await Test.createTestingModule({ - providers: [FilesService], - }).compile(); - - service = module.get(FilesService); - }); - - it("should be defined", () => { - expect(service).toBeDefined(); - }); -}); diff --git a/apps/backend/src/app/files/files.service.ts b/apps/backend/src/app/files/files.service.ts index 4bcc90f..8096be8 100644 --- a/apps/backend/src/app/files/files.service.ts +++ b/apps/backend/src/app/files/files.service.ts @@ -12,25 +12,25 @@ export class FilesService { private readonly database: DbService, ) {} - /** - * Fetches a file and its information based on the provided checksum. - * - * @param {string} checksum - The unique identifier for the file. - * @return {Promise>} An object containing the stream of the file, its information, and additional data. - * @throws {NotFoundException} If the file with the given checksum is not found. - */ - public async get(checksum: string): Promise> { + /** + * Retrieves a file and its related information from the database and associated storage. + * + * @param fileId The unique identifier for the file to be retrieved. + * @return A promise that resolves to an object containing the streamable file and additional file information. + * @throws NotFoundException if the file does not exist in the database. + */ + public async get(fileId: string): Promise> { const foundFiles = await this.database .use() .select() .from(FilesTable) - .where(eq(FilesTable.checksum, checksum)) - .prepare("getFileFromChecksum") + .where(eq(FilesTable.uuid, fileId)) + .prepare("getFileFromId") .execute(); if (foundFiles.length === 0) - throw new NotFoundException("File with checksum not found", { - description: `checksum : ${checksum}` + throw new NotFoundException("File not found", { + description: `Identifier : ${fileId}` }); if (foundFiles.length > 1)