Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fs rather than fs.promises for createWriteStream. Fixes #1840 #1841

Merged
merged 1 commit into from
Aug 6, 2020
Merged
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
9 changes: 5 additions & 4 deletions src/routers/InteractiveCompute/job-files/start.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const {spawn} = require('child_process');
const WebSocket = require('ws');
const fs = require('fs').promises;
const fs = require('fs');
const fsp = require('fs').promises;
const { promisify } = require('util');
const pipeline = promisify(require('stream').pipeline);
const path = require('path');
Expand Down Expand Up @@ -48,7 +49,7 @@ class InteractiveClient {
const stream = await client.getFileStream(dataInfo);
await pipeline(stream, fs.createWriteStream(dataPath));
const filePath = path.join(...dirs.concat('__init__.py'));
await fs.writeFile(filePath, initFile(name, type));
await fsp.writeFile(filePath, initFile(name, type));
}

this.runTask(saveArtifact);
Expand All @@ -69,7 +70,7 @@ class InteractiveClient {
async writeFile(filepath, content) {
const dirs = path.dirname(filepath).split(path.sep);
await mkdirp(...dirs);
await fs.writeFile(filepath, content);
await fsp.writeFile(filepath, content);
}

async runTask(fn) {
Expand Down Expand Up @@ -114,7 +115,7 @@ async function mkdirp() {
await dirs.reduce(async (lastDirPromise, nextDir) => {
const dir = path.join(await lastDirPromise, nextDir);
try {
await fs.mkdir(dir);
await fsp.mkdir(dir);
} catch (err) {
if (err.code !== 'EEXIST') {
throw err;
Expand Down