Offline fixes
This commit is contained in:
parent
16b58256c4
commit
d62e63acb8
|
@ -263,11 +263,12 @@ namespace MediaBrowser.Controller.Entities
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LazyInitializer.EnsureInitialized(ref _resolveArgs, ref _resolveArgsInitialized, ref _resolveArgsSyncLock, () => CreateResolveArgs());
|
LazyInitializer.EnsureInitialized(ref _resolveArgs, ref _resolveArgsInitialized, ref _resolveArgsSyncLock, () => CreateResolveArgs());
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
Logger.ErrorException("Error creating resolve args for ", ex, Path);
|
Logger.ErrorException("Error creating resolve args for {0}", ex, Path);
|
||||||
|
|
||||||
|
IsOffline = true;
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
@ -300,8 +301,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
var path = Path;
|
var path = Path;
|
||||||
|
|
||||||
// non file-system entries will not have a path
|
if (LocationType == LocationType.Remote || LocationType == LocationType.Virtual)
|
||||||
if (LocationType != LocationType.FileSystem || string.IsNullOrEmpty(path))
|
|
||||||
{
|
{
|
||||||
return new ItemResolveArgs(ConfigurationManager.ApplicationPaths);
|
return new ItemResolveArgs(ConfigurationManager.ApplicationPaths);
|
||||||
}
|
}
|
||||||
|
@ -314,24 +314,13 @@ namespace MediaBrowser.Controller.Entities
|
||||||
isDirectory = true;
|
isDirectory = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pathInfo = pathInfo ?? (isDirectory ? new DirectoryInfo(path) : FileSystem.GetFileSystemInfo(path));
|
pathInfo = pathInfo ?? (isDirectory ? new DirectoryInfo(path) : FileSystem.GetFileSystemInfo(path));
|
||||||
}
|
|
||||||
catch (IOException)
|
|
||||||
{
|
|
||||||
IsOffline = true;
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathInfo == null || !pathInfo.Exists)
|
if (pathInfo == null || !pathInfo.Exists)
|
||||||
{
|
{
|
||||||
IsOffline = true;
|
|
||||||
throw new IOException("Unable to retrieve file system info for " + path);
|
throw new IOException("Unable to retrieve file system info for " + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
IsOffline = false;
|
|
||||||
|
|
||||||
var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths)
|
var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths)
|
||||||
{
|
{
|
||||||
FileInfo = pathInfo,
|
FileInfo = pathInfo,
|
||||||
|
@ -367,6 +356,8 @@ namespace MediaBrowser.Controller.Entities
|
||||||
//update our dates
|
//update our dates
|
||||||
EntityResolutionHelper.EnsureDates(this, args);
|
EntityResolutionHelper.EnsureDates(this, args);
|
||||||
|
|
||||||
|
IsOffline = false;
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using MediaBrowser.Common.Extensions;
|
using System.Collections;
|
||||||
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Progress;
|
using MediaBrowser.Common.Progress;
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
|
@ -645,8 +646,18 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
//get the current valid children from filesystem (or wherever)
|
IEnumerable<BaseItem> nonCachedChildren;
|
||||||
var nonCachedChildren = IsOffline ? new BaseItem[] { } : GetNonCachedChildren();
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
nonCachedChildren = GetNonCachedChildren();
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
nonCachedChildren = new BaseItem[] { };
|
||||||
|
|
||||||
|
Logger.ErrorException("Error getting file system entries for {0}", ex, Path);
|
||||||
|
}
|
||||||
|
|
||||||
if (nonCachedChildren == null) return; //nothing to validate
|
if (nonCachedChildren == null) return; //nothing to validate
|
||||||
|
|
||||||
|
@ -685,6 +696,8 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
validChildren.Add(new Tuple<BaseItem, bool>(currentChild, false));
|
validChildren.Add(new Tuple<BaseItem, bool>(currentChild, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentChild.IsOffline = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -707,6 +720,8 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
if (IsRootPathAvailable(item.Path))
|
if (IsRootPathAvailable(item.Path))
|
||||||
{
|
{
|
||||||
|
item.IsOffline = false;
|
||||||
|
|
||||||
BaseItem removed;
|
BaseItem removed;
|
||||||
|
|
||||||
if (!_children.TryRemove(item.Id, out removed))
|
if (!_children.TryRemove(item.Id, out removed))
|
||||||
|
@ -717,7 +732,6 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
LibraryManager.ReportItemRemoved(item);
|
LibraryManager.ReportItemRemoved(item);
|
||||||
}
|
}
|
||||||
item.IsOffline = false;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -854,6 +868,11 @@ namespace MediaBrowser.Controller.Entities
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private bool IsRootPathAvailable(string path)
|
private bool IsRootPathAvailable(string path)
|
||||||
{
|
{
|
||||||
|
if (File.Exists(path))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Depending on whether the path is local or unc, it may return either null or '\' at the top
|
// Depending on whether the path is local or unc, it may return either null or '\' at the top
|
||||||
while (!string.IsNullOrEmpty(path) && path.Length > 1)
|
while (!string.IsNullOrEmpty(path) && path.Length > 1)
|
||||||
{
|
{
|
||||||
|
@ -874,19 +893,13 @@ namespace MediaBrowser.Controller.Entities
|
||||||
/// <returns>IEnumerable{BaseItem}.</returns>
|
/// <returns>IEnumerable{BaseItem}.</returns>
|
||||||
protected virtual IEnumerable<BaseItem> GetNonCachedChildren()
|
protected virtual IEnumerable<BaseItem> GetNonCachedChildren()
|
||||||
{
|
{
|
||||||
IEnumerable<FileSystemInfo> fileSystemChildren;
|
|
||||||
|
|
||||||
try
|
if (ResolveArgs == null || ResolveArgs.FileSystemDictionary == null)
|
||||||
{
|
{
|
||||||
fileSystemChildren = ResolveArgs.FileSystemChildren;
|
Logger.Error("Null for {0}", Path);
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path);
|
|
||||||
return new List<BaseItem>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return LibraryManager.ResolvePaths<BaseItem>(fileSystemChildren, this);
|
return LibraryManager.ResolvePaths<BaseItem>(ResolveArgs.FileSystemChildren, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user