hotfix: resolve data directory (#288)

This commit is contained in:
Carlos Valente
2023-02-17 20:23:00 +01:00
committed by GitHub
parent 298af3ec5a
commit df351b8cba
3 changed files with 7 additions and 11 deletions
@@ -27,9 +27,8 @@ export const poll = async (req, res) => {
export const dbDownload = async (req, res) => {
const { title } = DataProvider.getEventData();
const fileTitle = title || 'ontime data';
const dbInDisk = resolveDbPath();
res.download(dbInDisk, `${fileTitle}.json`, (err) => {
res.download(resolveDbPath, `${fileTitle}.json`, (err) => {
if (err) {
res.status(500).send({
message: `Could not download the file: ${err}`,
+3 -6
View File
@@ -292,8 +292,7 @@ export const validateEvent = (eventArgs) => {
const e = eventArgs;
const d = eventDef;
const start =
e.timeStart != null && typeof e.timeStart === 'number' ? e.timeStart : d.timeStart;
const start = e.timeStart != null && typeof e.timeStart === 'number' ? e.timeStart : d.timeStart;
const end = e.timeEnd != null && typeof e.timeEnd === 'number' ? e.timeEnd : d.timeEnd;
event = {
@@ -344,9 +343,7 @@ export const fileHandler = async (file) => {
try {
const excelData = xlsx
.parse(file, { cellDates: true })
.find(
({ name }) => name.toLowerCase() === 'ontime' || name.toLowerCase() === 'event schedule'
);
.find(({ name }) => name.toLowerCase() === 'ontime' || name.toLowerCase() === 'event schedule');
// we only look at worksheets called ontime or event schedule
if (excelData?.data) {
@@ -379,7 +376,7 @@ export const fileHandler = async (file) => {
return { error: true, message: 'Error parsing JSON file' };
}
if (uploadedJson.settings.version === 1) {
if (uploadedJson.settings.version === 2) {
try {
res.data = await parseJson(uploadedJson);
res.message = 'success';