diff --git a/MediaBrowser.Controller/Xml/BaseItemXmlParser.cs b/MediaBrowser.Controller/Xml/BaseItemXmlParser.cs
index 6c7a265fa..1fdd3218f 100644
--- a/MediaBrowser.Controller/Xml/BaseItemXmlParser.cs
+++ b/MediaBrowser.Controller/Xml/BaseItemXmlParser.cs
@@ -17,37 +17,33 @@ namespace MediaBrowser.Controller.Xml
///
/// Fetches metadata for an item from one xml file
///
- public Task Fetch(T item, string metadataFile)
+ public async Task Fetch(T item, string metadataFile)
{
- // Wrapping this for now until I have a chance to async the whole process
- return Task.Run(() =>
+ // Use XmlReader for best performance
+ using (XmlReader reader = XmlReader.Create(metadataFile, new XmlReaderSettings() { Async = true }))
{
- // Use XmlReader for best performance
- using (XmlReader reader = XmlReader.Create(metadataFile))
- {
- reader.MoveToContent();
+ await reader.MoveToContentAsync();
- // Loop through each element
- while (reader.Read())
+ // Loop through each element
+ while (await reader.ReadAsync())
+ {
+ if (reader.NodeType == XmlNodeType.Element)
{
- if (reader.NodeType == XmlNodeType.Element)
- {
- FetchDataFromXmlNode(reader, item);
- }
+ FetchDataFromXmlNode(reader, item);
}
}
+ }
- // If dates weren't supplied in metadata, use values from the xml file
- if (item.DateCreated == DateTime.MinValue)
- {
- item.DateCreated = File.GetCreationTime(metadataFile);
- }
+ // If dates weren't supplied in metadata, use values from the xml file
+ if (item.DateCreated == DateTime.MinValue)
+ {
+ item.DateCreated = File.GetCreationTime(metadataFile);
+ }
- if (item.DateModified == DateTime.MinValue)
- {
- item.DateModified = File.GetLastWriteTime(metadataFile);
- }
- });
+ if (item.DateModified == DateTime.MinValue)
+ {
+ item.DateModified = File.GetLastWriteTime(metadataFile);
+ }
}
///