From 642589e0baf72ee87de28030ae682d449afa4733 Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Tue, 17 Mar 2026 14:47:59 +0000 Subject: [PATCH] lib: Make listSegmentations return ecotaxa export --- lib/db.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/db.js b/lib/db.js index 2a08f26a2..bff426cfc 100644 --- a/lib/db.js +++ b/lib/db.js @@ -8,7 +8,7 @@ import { stat, } from "fs/promises" import { parse } from "csv-parse" -import { createReadStream } from "fs" +import { createReadStream, exists } from "fs" export const DATA_PATH = "/home/pi/data" export const PATH_ACQUISITION = join(DATA_PATH, "img") @@ -205,6 +205,20 @@ async function getSegmentationFromPath(path) { const acquisition_id = tsv_row.acq_id.split(sample_id + "_")[1] || tsv_row.acq_id + let ecotaxa_export_relative_path = join( + "export/ecotaxa", + `ecotaxa_${acquisition_id}.zip`, + ) + console.log(ecotaxa_export_relative_path) + let ecotaxa_export_exists = false + try { + await access(join(DATA_PATH, ecotaxa_export_relative_path), constants.F_OK) + ecotaxa_export_exists = true + } catch (err) { + if (err.code !== "ENOENT") throw err + ecotaxa_export_exists = false + } + const segmentation = { project_name, sample_id, @@ -213,6 +227,9 @@ async function getSegmentationFromPath(path) { path, gallery: getGalleryPath(path), date: stats.birthtime.toISOString(), + ecotaxa_export: ecotaxa_export_exists + ? join("/api/files/", path_relative) + : null, } return segmentation