Skip to content

Commit

Permalink
remove tmp directory upon successful processing (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
miklcct authored Oct 7, 2024
1 parent d1dd32b commit 7461158
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 64 deletions.
60 changes: 1 addition & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"adm-zip": "^0.5.10",
"byline": "^5.0.0",
"csv-write-stream": "^2.0.0",
"fs-extra": "^11.1.1",
"memoized-class-decorator": "^1.6.1",
"moment": "^2.29.4",
"mysql2": "^3.6.1",
Expand All @@ -53,12 +52,11 @@
"stream-to-promise": "^3.0.0"
},
"engines": {
"node": "^14.0.0"
"node": "^14.14.0"
},
"devDependencies": {
"@types/byline": "^4.2.33",
"@types/chai": "^4.3.6",
"@types/fs-extra": "^11.0.1",
"@types/mocha": "^10.0.1",
"@types/node": "^16.11.6",
"@types/ssh2": "^1.11.13",
Expand Down
5 changes: 3 additions & 2 deletions src/cli/ImportFeedCommand.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import AdmZip = require("adm-zip");
import * as fs from 'fs';
import {CLICommand} from "./CLICommand";
import {FeedConfig} from "../../config";
import {FeedFile} from "../feed/file/FeedFile";
Expand All @@ -7,7 +8,6 @@ import {DatabaseConnection} from "../database/DatabaseConnection";
import * as path from "path";
import {MySQLTable} from "../database/MySQLTable";
import * as memoize from "memoized-class-decorator";
import fs = require("fs-extra");
import {MultiRecordFile} from "../feed/file/MultiRecordFile";
import {RecordWithManualIdentifier} from "../feed/record/FixedWidthRecord";
import {MySQLStream, TableIndex} from "../database/MySQLStream";
Expand Down Expand Up @@ -46,7 +46,7 @@ export class ImportFeedCommand implements CLICommand {
*/
public async doImport(filePath: string): Promise<void> {
console.log(`Extracting ${filePath} to ${this.tmpFolder}`);
fs.emptyDirSync(this.tmpFolder);
fs.rmSync(this.tmpFolder, {recursive: true, force: true});

new AdmZip(filePath).extractAllTo(this.tmpFolder);

Expand All @@ -73,6 +73,7 @@ export class ImportFeedCommand implements CLICommand {
}

await this.updateLastFile(zipName);
fs.rmSync(this.tmpFolder, { recursive: true });
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/cli/OutputGTFSZipCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class OutputGTFSZipCommand implements CLICommand {
setTimeout(() => {
console.log("Writing " + filename);
processSpawnResult(spawnSync('zip', ['-jr', filename, argv[3]]));
fs.rmSync(argv[3], {recursive: true});
}, 1000);
}

Expand Down

0 comments on commit 7461158

Please sign in to comment.