Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion lib/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down