From 3021d1cac14936b566b4a3dca72f4755cd77cf96 Mon Sep 17 00:00:00 2001 From: Meelyn Pandit Date: Mon, 20 Jul 2026 11:50:44 -0400 Subject: [PATCH 1/2] fix(tag-db): import fs so SG tag database uploads persist The /upload-sg-tag-file handler calls fs.writeFileSync() but never imported fs, so every upload threw `ReferenceError: fs is not defined` after the handler had already run `rm /data/sg_files/SG_tag_database*`. Net effect: uploading a tag database deleted the existing one and wrote nothing, leaving an empty/missing SG_tag_database.sqlite and causing the SensorGnome interface to fail with `no such table: tags`. Add the missing `import fs from 'fs'`. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/station-interface/routes/sensorgnome/upload-sg-tag-file.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/station-interface/routes/sensorgnome/upload-sg-tag-file.js b/src/station-interface/routes/sensorgnome/upload-sg-tag-file.js index b1c48278..b1ab14fa 100644 --- a/src/station-interface/routes/sensorgnome/upload-sg-tag-file.js +++ b/src/station-interface/routes/sensorgnome/upload-sg-tag-file.js @@ -1,3 +1,5 @@ +import fs from 'fs' + import RunCommand from '../../../command.js' const BASE_SG_TAG_DB_NAME = 'SG_tag_database' From 4e52ec4a716ec26e8e88968489e29a406bd30b80 Mon Sep 17 00:00:00 2001 From: Meelyn Pandit Date: Wed, 22 Jul 2026 13:48:07 -0400 Subject: [PATCH 2/2] fix(tag-db): rm -f so first-time tag DB upload (no existing file) works The handler deletes /data/sg_files/SG_tag_database* before writing the new file. On a station that has no tag DB yet the glob matches nothing, so plain rm exits non-zero; RunCommand rejects and the upload aborts before fs.writeFileSync runs, surfacing "Command failed: rm ... No such file or directory". Use rm -f so an empty match is treated as success. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../routes/sensorgnome/upload-sg-tag-file.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/station-interface/routes/sensorgnome/upload-sg-tag-file.js b/src/station-interface/routes/sensorgnome/upload-sg-tag-file.js index b1ab14fa..6fbf7c71 100644 --- a/src/station-interface/routes/sensorgnome/upload-sg-tag-file.js +++ b/src/station-interface/routes/sensorgnome/upload-sg-tag-file.js @@ -9,7 +9,10 @@ export default (req, res, next) => { const ext = req.get('file-extension') const filename = `${BASE_SG_TAG_DB_NAME}.${ext}` console.log('about to delete sg tag db files') - RunCommand(`rm /data/sg_files/${BASE_SG_TAG_DB_NAME}*`) + // Use rm -f: on a station with no existing tag DB the glob matches nothing, + // and a plain rm exits non-zero, rejecting the promise before the write ever + // runs. -f treats "nothing to remove" as success. + RunCommand(`rm -f /data/sg_files/${BASE_SG_TAG_DB_NAME}*`) .then(() => { let uri = `/data/sg_files/${filename}` console.log('writing tag database file')