The Free Software Media System - Server Backend & API
update offline detection
Luke Pulverentie90072b75faf
diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.csindex 4cdc4657e3..04d42e16f3 100644--- a/MediaBrowser.Controller/Entities/Folder.cs+++ b/MediaBrowser.Controller/Entities/Folder.cs@@ -702,7 +702,7 @@ namespace MediaBrowser.Controller.Entities/// </summary>/// <param name="path">The path.</param>/// <returns><c>true</c> if the specified path is offline; otherwise, <c>false</c>.</returns>- private bool IsPathOffline(string path)+ public static bool IsPathOffline(string path){if (FileSystem.FileExists(path)){@@ -736,12 +736,12 @@ namespace MediaBrowser.Controller.Entities/// <param name="folders">The folders.</param>/// <param name="path">The path.</param>/// <returns><c>true</c> if the specified folders contains path; otherwise, <c>false</c>.</returns>- private bool ContainsPath(IEnumerable<VirtualFolderInfo> folders, string path)+ private static bool ContainsPath(IEnumerable<VirtualFolderInfo> folders, string path){return folders.SelectMany(i => i.Locations).Any(i => ContainsPath(i, path));}- private bool ContainsPath(string parent, string path)+ private static bool ContainsPath(string parent, string path){return string.Equals(parent, path, StringComparison.OrdinalIgnoreCase) || FileSystem.ContainsSubPath(parent, path);}diff --git a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.csindex c9f7165cb5..709ed5ec9a 100644--- a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs+++ b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs@@ -184,15 +184,24 @@ namespace MediaBrowser.Server.Implementations.Persistencetry{- if (!_fileSystem.FileExists(path) && !_fileSystem.DirectoryExists(path))+ if (_fileSystem.FileExists(path) || _fileSystem.DirectoryExists(path)){- var libraryItem = _libraryManager.GetItemById(item.Item1);+ continue;+ }++ var libraryItem = _libraryManager.GetItemById(item.Item1);- await _libraryManager.DeleteItem(libraryItem, new DeleteOptions- {- DeleteFileLocation = false- });+ if (Folder.IsPathOffline(path))+ {+ libraryItem.IsOffline = true;+ await libraryItem.UpdateToRepository(ItemUpdateType.None, cancellationToken).ConfigureAwait(false);+ continue;}++ await _libraryManager.DeleteItem(libraryItem, new DeleteOptions+ {+ DeleteFileLocation = false+ });}catch (OperationCanceledException){