fix unstage issues

Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
Travis Glenn Hansen 2022-05-25 17:08:18 -06:00
parent 7fd385d2d0
commit a81246664b
2 changed files with 16 additions and 1 deletions

View File

@ -117,6 +117,10 @@ function stripWindowsDriveLetter(path) {
return path.replace(/^[a-zA-Z]:/, "");
}
function hasWindowsDriveLetter(path) {
return /^[a-zA-Z]:/i.test(path);
}
/**
* transition function to replicate `request` style requests using axios
*
@ -253,6 +257,7 @@ module.exports.lockKeysFromRequest = lockKeysFromRequest;
module.exports.getLargestNumber = getLargestNumber;
module.exports.stringify = stringify;
module.exports.stripWindowsDriveLetter = stripWindowsDriveLetter;
module.exports.hasWindowsDriveLetter = hasWindowsDriveLetter;
module.exports.axios_request = axios_request;
module.exports.default_supported_block_filesystems =
default_supported_block_filesystems;

View File

@ -1,5 +1,5 @@
const { result } = require("lodash");
const _ = require("lodash");
const GeneralUtils = require("./general");
const Powershell = require("./powershell").Powershell;
/**
@ -757,6 +757,16 @@ class Windows {
async UnmountVolume(volumeId, path) {
let command;
// this errors if it does not have a drive letter
if (!GeneralUtils.hasWindowsDriveLetter(path)) {
let item = await this.GetItem(path);
if (!item) {
return;
}
path = item.FullName;
}
command = `Get-Volume -UniqueId \"${volumeId}\" | Get-Partition | Remove-PartitionAccessPath -AccessPath ${path}`;
await this.ps.exec(command);