Remove file service tests and update get method parameter
Removed the `files.service.spec.ts` test file as it is no longer required. Updated the `get` method parameter in `files.service.ts` to use `fileId` instead of `checksum`, and adjusted the related logic for consistency.
This commit is contained in:
parent
4d7ae970bc
commit
310a806c87
@ -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>(FilesService);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should be defined", () => {
|
|
||||||
expect(service).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
@ -13,24 +13,24 @@ export class FilesService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches a file and its information based on the provided checksum.
|
* Retrieves a file and its related information from the database and associated storage.
|
||||||
*
|
*
|
||||||
* @param {string} checksum - The unique identifier for the file.
|
* @param fileId The unique identifier for the file to be retrieved.
|
||||||
* @return {Promise<IFileWithInformation<object>>} An object containing the stream of the file, its information, and additional data.
|
* @return A promise that resolves to an object containing the streamable file and additional file information.
|
||||||
* @throws {NotFoundException} If the file with the given checksum is not found.
|
* @throws NotFoundException if the file does not exist in the database.
|
||||||
*/
|
*/
|
||||||
public async get(checksum: string): Promise<IFileWithInformation<object>> {
|
public async get(fileId: string): Promise<IFileWithInformation<object>> {
|
||||||
const foundFiles = await this.database
|
const foundFiles = await this.database
|
||||||
.use()
|
.use()
|
||||||
.select()
|
.select()
|
||||||
.from(FilesTable)
|
.from(FilesTable)
|
||||||
.where(eq(FilesTable.checksum, checksum))
|
.where(eq(FilesTable.uuid, fileId))
|
||||||
.prepare("getFileFromChecksum")
|
.prepare("getFileFromId")
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
if (foundFiles.length === 0)
|
if (foundFiles.length === 0)
|
||||||
throw new NotFoundException("File with checksum not found", {
|
throw new NotFoundException("File not found", {
|
||||||
description: `checksum : ${checksum}`
|
description: `Identifier : ${fileId}`
|
||||||
});
|
});
|
||||||
|
|
||||||
if (foundFiles.length > 1)
|
if (foundFiles.length > 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user