Skip to content

Commit 067cc3e

Browse files
committed
Temporary fix to mkdir for import command + import should not keep existing
1 parent 445c050 commit 067cc3e

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

bin/commands/import.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ class ImportCommand extends DaemonCommand {
5959
const localMirror = mirrorFolder(args.dir, { fs: drive, name: '/' }, {
6060
watch: true,
6161
dereference: true,
62-
keepExisting: true,
62+
// When going from fs -> drive, it should overwrite.
63+
keepExisting: false,
6364
ignore: (file, stat, cb) => {
6465
if (shouldIgnore(file)) return process.nextTick(cb, null, true)
6566
return process.nextTick(cb, null, false)

lib/clients/drive.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,14 @@ class RemoteHyperdrive {
444444

445445
return maybe(cb, new Promise((resolve, reject) => {
446446
this._client.mkdir(req, toMetadata({ token: this.token }), (err, rsp) => {
447-
if (err) return reject(err)
447+
if (err) {
448+
// TODO: Found this bug late, and it hightlights the need for more structured errors from gRPC.
449+
// This is the most straightforward way to fix the import command, but the API should be updated to handle this.
450+
if (err.details && err.details.indexOf('Path already')) {
451+
err.code = 'EEXIST'
452+
}
453+
return reject(err)
454+
}
448455
return resolve()
449456
})
450457
}))

0 commit comments

Comments
 (0)