Skip to content

Commit

Permalink
Do not delete static sources that are being reused
Browse files Browse the repository at this point in the history
  • Loading branch information
julianrojas87 committed Jul 7, 2022
1 parent 0d46b34 commit 644d2b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/GtfsIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,10 @@ class GtfsIndex {
}

async cleanUp() {
await del([this.auxPath], { force: true });
// We don't want to delete sources that are probably been reused
if(this.auxPath !== this.path) {
await del([this.auxPath], { force: true });
}
}

get path() {
Expand Down
6 changes: 4 additions & 2 deletions test/gtfsrt2lc.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const fs = require('fs');
const del = require('del');
const GtfsIndex = require('../lib/GtfsIndex');
const Gtfsrt2lc = require('../lib/Gtfsrt2LC');
const Utils = require('../lib/Utils');
Expand Down Expand Up @@ -108,6 +109,7 @@ test('Extract all indexes when source is given as decompressed folder', async ()
expect(indexes.trips).toBeDefined();
expect(indexes.stops).toBeDefined();
expect(indexes.stop_times).toBeDefined();
await del(['./test/data/decompressed'], { force: true });
});

test('Check all parsed connections are consistent regarding departure and arrival times', async () => {
Expand Down Expand Up @@ -544,7 +546,7 @@ test('Test measures to produce consistent connections', () => {

// Test arrival is added with the current departure delay
update['arrival'] = undefined;
let prevUpdate = {"departure": { "delay": 3600 }};
let prevUpdate = { "departure": { "delay": 3600 } };
let timestamp = new Date('2020-03-03T08:21:00.000Z').getTime() / 1000;
grt.checkUpdate(update, prevUpdate, staticData, 2, 10, serviceDay, timestamp);
expect(update['arrival']['delay']).toBe(3600);
Expand All @@ -554,7 +556,7 @@ test('Test measures to produce consistent connections', () => {
update['arrival'] = undefined;
update['departure']['delay'] = 60;
update['departure']['time'] = new Date('2020-03-03T08:31:00.000Z').getTime() / 1000;
prevUpdate = {"departure": { "delay": 3600 }};
prevUpdate = { "departure": { "delay": 3600 } };
timestamp = new Date('2020-03-03T10:21:00.000Z').getTime() / 1000;
grt.checkUpdate(update, prevUpdate, staticData, 2, 10, serviceDay, timestamp);
expect(update['arrival']['delay']).toBe(60);
Expand Down

0 comments on commit 644d2b8

Please sign in to comment.