Skip to content

Commit

Permalink
Find versions based on filename instead of s3key
Browse files Browse the repository at this point in the history
  • Loading branch information
tukiains committed Nov 25, 2024
1 parent 3b8fd92 commit cf31d8b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion backend/src/routes/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ export class FileRoutes {

async fetchValidVersions(queryRunner: QueryRunner, file: File) {
return await queryRunner.manager.find(RegularFile, {
where: { s3key: s3Key(file), tombstoneReason: IsNull() },
where: { filename: s3Key(file), tombstoneReason: IsNull() },
relations: { product: true, site: true },
order: { createdAt: "DESC" },
});
Expand Down
9 changes: 4 additions & 5 deletions backend/tests/integration/sequential/file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,10 @@ describe("DELETE /api/files/", () => {
const categorizeFile = await putDummyFile({ product: "categorize", sourceFileIds: [radarFile.uuid] });
await putDummyImage("categorize-ldr.png", categorizeFile);
await expect(deleteFile(radarFile.uuid, true, false)).resolves.toMatchObject({ status: 200 });
// await expect(fileRepo.findOneBy({ uuid: radarFile.uuid })).resolves.toBeFalsy();
// await expect(fileRepo.findOneBy({ uuid: categorizeFile.uuid })).resolves.toBeFalsy();
// await expect(vizRepo.findOneBy({ s3key: "radar-v.png" })).resolves.toBeFalsy();
// await expect(vizRepo.findOneBy({ s3key: "categorize-ldr.png" })).resolves.toBeFalsy();
await expect(fileRepo.findOneBy({ uuid: radarFile.uuid })).resolves.toBeFalsy();
await expect(fileRepo.findOneBy({ uuid: categorizeFile.uuid })).resolves.toBeFalsy();
await expect(vizRepo.findOneBy({ s3key: "radar-v.png" })).resolves.toBeFalsy();
await expect(vizRepo.findOneBy({ s3key: "categorize-ldr.png" })).resolves.toBeFalsy();
});

it("does not delete with dryRun parameter", async () => {
Expand Down Expand Up @@ -896,7 +896,6 @@ describe("DELETE /api/files/", () => {
if (legacy) file.legacy = true;
if (product === "model" && !file.model) file.model = "ecmwf";
const bucketFix = volatile ? "-volatile" : "";
console.log(file);
await axios.put(`${storageServiceUrl}cloudnet-product${bucketFix}/${file.s3key}`, "content");
await expect(putFile(file)).resolves.toMatchObject({ status: statusCode });
return file;
Expand Down

0 comments on commit cf31d8b

Please sign in to comment.