Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
virtualbox.snapshotList(VirtualBoxManager.vmName, function (error, snapshotList, currentSnapshotUUID)
{
if (snapshotList && snapshotList instanceof Array)
{
const snapshotExists = _.filter(snapshotList, function (snapshot)
{
return snapshot.name === snapshotName;
}).length > 0;
if (snapshotExists)
{
const virtualbox = require("virtualbox");
virtualbox.snapshotDelete(VirtualBoxManager.vmName, snapshotName, function (error)
{
if (error) throw error;
else
{
VirtualBoxManager._deletedSnapshots[snapshotName] = true;
Logger.log("Snapshot " + snapshotName + " has been deleted!");
callback(error);
}
});
}
else
{
callback(null);
}
}
else