Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import fs from 'fs'

import RunCommand from '../../../command.js'

const BASE_SG_TAG_DB_NAME = 'SG_tag_database'
Expand All @@ -7,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')
Expand Down