diff --git a/packages/vhd-lib/Vhd/VhdFile.js b/packages/vhd-lib/Vhd/VhdFile.js index d32471d4e..376419181 100644 --- a/packages/vhd-lib/Vhd/VhdFile.js +++ b/packages/vhd-lib/Vhd/VhdFile.js @@ -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 : diff --git a/packages/vhd-lib/openVhd.js b/packages/vhd-lib/openVhd.js index ce7632b9b..8852cbafe 100644 --- a/packages/vhd-lib/openVhd.js +++ b/packages/vhd-lib/openVhd.js @@ -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)