fix(vhd-lib): improve openVhd error handling
This commit is contained in:
parent
0cf6f94677
commit
545a65521a
@ -83,7 +83,9 @@ exports.VhdFile = class VhdFile extends VhdAbstract {
|
||||
}
|
||||
|
||||
static async open(handler, path, { flags, checkSecondFooter = true } = {}) {
|
||||
assert(!handler.isEncrypted, `VHDFile implementation is not compatible with encrypted remote`)
|
||||
if (handler.isEncrypted) {
|
||||
throw new Error(`VHDFile implementation is not compatible with encrypted remote`)
|
||||
}
|
||||
const fd = await handler.openFile(path, flags ?? 'r+')
|
||||
const vhd = new VhdFile(handler, fd)
|
||||
// openning a file for reading does not trigger EISDIR as long as we don't really read from it :
|
||||
|
@ -9,8 +9,7 @@ exports.openVhd = async function openVhd(handler, path, opts) {
|
||||
try {
|
||||
return await VhdFile.open(handler, resolved, opts)
|
||||
} catch (e) {
|
||||
// if the remote is encrypted, trying to open a VhdFile will throw an assertion error before checking if the path is a directory, therefore we should try to open a VhdDirectory anyway.
|
||||
if (e.code !== 'EISDIR' && e.code !== 'ERR_ASSERTION') {
|
||||
if (e.code !== 'EISDIR') {
|
||||
throw e
|
||||
}
|
||||
return await VhdDirectory.open(handler, resolved, opts)
|
||||
|
Loading…
Reference in New Issue
Block a user