diff options
author | Kenneth Skovhede <kenneth@hexad.dk> | 2022-06-12 21:27:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-12 21:27:59 +0300 |
commit | b62ff1876a3f97d37ace58bbab7395dc8866abda (patch) | |
tree | b18d29c5c2cdfe346cec00e6b80ac2e9da2f0ae2 | |
parent | 8f2c1153f9aa30d6f90448e1833d593c7f5a5be5 (diff) | |
parent | ed5d2c23c6a77a1cd502c3b843dbfd4a62d30442 (diff) |
Merge pull request #4676 from awerghcpc/hyperv-argumentnullexception-fix
Added null check to fix exception reading vhd settings xml.
-rw-r--r-- | Duplicati/Library/Snapshots/HyperVUtility.cs | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/Duplicati/Library/Snapshots/HyperVUtility.cs b/Duplicati/Library/Snapshots/HyperVUtility.cs index 338706c85..423b24911 100644 --- a/Duplicati/Library/Snapshots/HyperVUtility.cs +++ b/Duplicati/Library/Snapshots/HyperVUtility.cs @@ -302,7 +302,16 @@ namespace Duplicati.Library.Snapshots select ((string[])systemBaseObj["Connection"])[0]).ToList();
foreach (var vhd in tempvhd)
- result.Add(vhd);
+ {
+ if (File.Exists(vhd))
+ {
+ result.Add(vhd);
+ }
+ else
+ {
+ Logging.Log.WriteWarningMessage(LOGTAG, "HyperVInvalidVhd", null, "Invalid VHD file detected, file does not exist: {0}", vhd);
+ }
+ }
}
}
@@ -319,11 +328,16 @@ namespace Duplicati.Library.Snapshots if (outParams != null)
{
var doc = new System.Xml.XmlDocument();
- doc.LoadXml((string)outParams[_wmiv2Namespace ? "SettingData" : "Info"]);
- var node = doc.SelectSingleNode("//PROPERTY[@NAME = 'ParentPath']/VALUE/child::text()");
+ var propertyValue = (string)outParams[_wmiv2Namespace ? "SettingData" : "Info"];
+
+ if (propertyValue != null)
+ {
+ doc.LoadXml(propertyValue);
+ var node = doc.SelectSingleNode("//PROPERTY[@NAME = 'ParentPath']/VALUE/child::text()");
- if (node != null && File.Exists(node.Value))
- ParentPaths.Add(node.Value);
+ if (node != null && File.Exists(node.Value))
+ ParentPaths.Add(node.Value);
+ }
}
}
}
|