beginnings of offline support
This commit is contained in:
parent
ae559e0ed1
commit
dc21adf1a4
|
@ -89,6 +89,9 @@ namespace MediaBrowser.Controller.Entities
|
||||||
/// <value>The path.</value>
|
/// <value>The path.</value>
|
||||||
public virtual string Path { get; set; }
|
public virtual string Path { get; set; }
|
||||||
|
|
||||||
|
[IgnoreDataMember]
|
||||||
|
protected internal bool IsOffline { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the type of the location.
|
/// Gets or sets the type of the location.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -97,6 +100,11 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
if (IsOffline)
|
||||||
|
{
|
||||||
|
return LocationType.Offline;
|
||||||
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(Path))
|
if (string.IsNullOrEmpty(Path))
|
||||||
{
|
{
|
||||||
return LocationType.Virtual;
|
return LocationType.Virtual;
|
||||||
|
@ -649,13 +657,20 @@ namespace MediaBrowser.Controller.Entities
|
||||||
// Support xbmc trailers (-trailer suffix on video file names)
|
// Support xbmc trailers (-trailer suffix on video file names)
|
||||||
files.AddRange(resolveArgs.FileSystemChildren.Where(i =>
|
files.AddRange(resolveArgs.FileSystemChildren.Where(i =>
|
||||||
{
|
{
|
||||||
if ((i.Attributes & FileAttributes.Directory) != FileAttributes.Directory)
|
try
|
||||||
{
|
{
|
||||||
if (System.IO.Path.GetFileNameWithoutExtension(i.Name).EndsWith(XbmcTrailerFileSuffix, StringComparison.OrdinalIgnoreCase) && !string.Equals(Path, i.FullName, StringComparison.OrdinalIgnoreCase))
|
if ((i.Attributes & FileAttributes.Directory) != FileAttributes.Directory)
|
||||||
{
|
{
|
||||||
return true;
|
if (System.IO.Path.GetFileNameWithoutExtension(i.Name).EndsWith(XbmcTrailerFileSuffix, StringComparison.OrdinalIgnoreCase) && !string.Equals(Path, i.FullName, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
Logger.ErrorException("Error accessing path {0}", ex, i.FullName);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -703,15 +703,23 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
foreach (var item in itemsRemoved)
|
foreach (var item in itemsRemoved)
|
||||||
{
|
{
|
||||||
BaseItem removed;
|
if (IsRootPathAvailable(item.Path))
|
||||||
|
|
||||||
if (!_children.TryRemove(item.Id, out removed))
|
|
||||||
{
|
{
|
||||||
Logger.Error("Failed to remove {0}", item.Name);
|
BaseItem removed;
|
||||||
|
|
||||||
|
if (!_children.TryRemove(item.Id, out removed))
|
||||||
|
{
|
||||||
|
Logger.Error("Failed to remove {0}", item.Name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LibraryManager.ReportItemRemoved(item);
|
||||||
|
}
|
||||||
|
item.IsOffline = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LibraryManager.ReportItemRemoved(item);
|
item.IsOffline = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -835,6 +843,28 @@ namespace MediaBrowser.Controller.Entities
|
||||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines if a path's root is available or not
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private bool IsRootPathAvailable(string path)
|
||||||
|
{
|
||||||
|
var parent = System.IO.Path.GetDirectoryName(path);
|
||||||
|
|
||||||
|
while (!string.IsNullOrEmpty(parent) && !parent.ToCharArray()[0].Equals(System.IO.Path.DirectorySeparatorChar))
|
||||||
|
{
|
||||||
|
if (Directory.Exists(parent))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
parent = System.IO.Path.GetDirectoryName(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the children of this folder from the actual file system
|
/// Get the children of this folder from the actual file system
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -973,7 +1003,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
var changed = await base.RefreshMetadata(cancellationToken, forceSave, forceRefresh, allowSlowProviders, resetResolveArgs).ConfigureAwait(false);
|
var changed = await base.RefreshMetadata(cancellationToken, forceSave, forceRefresh, allowSlowProviders, resetResolveArgs).ConfigureAwait(false);
|
||||||
|
|
||||||
return changed || (SupportsLinkedChildren && RefreshLinkedChildren());
|
return changed || (SupportsLinkedChildren && LocationType == LocationType.FileSystem && RefreshLinkedChildren());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -390,12 +390,21 @@ namespace MediaBrowser.Controller.Providers
|
||||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||||
private bool IncludeInFileStamp(FileSystemInfo file, string[] extensions)
|
private bool IncludeInFileStamp(FileSystemInfo file, string[] extensions)
|
||||||
{
|
{
|
||||||
if ((file.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
try
|
||||||
{
|
{
|
||||||
|
if ((file.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return extensions.Length == 0 || extensions.Contains(file.Extension, StringComparer.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
Logger.ErrorException("Error accessing file attributes for {0}", ex, file.FullName);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return extensions.Length == 0 || extensions.Contains(file.Extension, StringComparer.OrdinalIgnoreCase);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,10 @@ namespace MediaBrowser.Model.Entities
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The virtual
|
/// The virtual
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Virtual
|
Virtual,
|
||||||
|
/// <summary>
|
||||||
|
/// The offline
|
||||||
|
/// </summary>
|
||||||
|
Offline
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user