aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/Library
diff options
context:
space:
mode:
authorhatharry <hatharry@hotmail.com>2016-08-29 01:27:43 +1200
committerhatharry <hatharry@hotmail.com>2016-08-29 01:27:43 +1200
commitcabf2cdc1be4c06714ac6bcf835a19d2f652a6e2 (patch)
treed375b8a41e9fd40a2569ceea6b02e4f8237db797 /MediaBrowser.Api/Library
parente564b54686029a90595e1bb4277f87490763e183 (diff)
parentc974641a352685b2e6595dd7b291843c8e6364ac (diff)
Merge branch 'dev' of https://github.com/hatharry/Emby.git
Diffstat (limited to 'MediaBrowser.Api/Library')
-rw-r--r--MediaBrowser.Api/Library/FileOrganizationService.cs14
-rw-r--r--MediaBrowser.Api/Library/LibraryStructureService.cs32
2 files changed, 35 insertions, 11 deletions
diff --git a/MediaBrowser.Api/Library/FileOrganizationService.cs b/MediaBrowser.Api/Library/FileOrganizationService.cs
index 0ed08a860..ca391bef0 100644
--- a/MediaBrowser.Api/Library/FileOrganizationService.cs
+++ b/MediaBrowser.Api/Library/FileOrganizationService.cs
@@ -154,9 +154,12 @@ namespace MediaBrowser.Api.Library
public void Post(PerformOrganization request)
{
+ // Don't await this
var task = _iFileOrganizationService.PerformOrganization(request.Id);
- Task.WaitAll(task);
+ // Async processing (close dialog early instead of waiting until the file has been copied)
+ // Wait 2s for exceptions that may occur to have them forwarded to the client for immediate error display
+ task.Wait(2000);
}
public void Post(OrganizeEpisode request)
@@ -168,6 +171,7 @@ namespace MediaBrowser.Api.Library
dicNewProviderIds = request.NewSeriesProviderIds;
}
+ // Don't await this
var task = _iFileOrganizationService.PerformEpisodeOrganization(new EpisodeFileOrganizationRequest
{
EndingEpisodeNumber = request.EndingEpisodeNumber,
@@ -182,11 +186,9 @@ namespace MediaBrowser.Api.Library
TargetFolder = request.TargetFolder
});
- // For async processing (close dialog early instead of waiting until the file has been copied)
- //var tasks = new Task[] { task };
- //Task.WaitAll(tasks, 8000);
-
- Task.WaitAll(task);
+ // Async processing (close dialog early instead of waiting until the file has been copied)
+ // Wait 2s for exceptions that may occur to have them forwarded to the client for immediate error display
+ task.Wait(2000);
}
public object Get(GetSmartMatchInfos request)
diff --git a/MediaBrowser.Api/Library/LibraryStructureService.cs b/MediaBrowser.Api/Library/LibraryStructureService.cs
index 3cf0d5d93..72966a7cd 100644
--- a/MediaBrowser.Api/Library/LibraryStructureService.cs
+++ b/MediaBrowser.Api/Library/LibraryStructureService.cs
@@ -10,6 +10,9 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Model.Configuration;
namespace MediaBrowser.Api.Library
{
@@ -52,6 +55,8 @@ namespace MediaBrowser.Api.Library
/// </summary>
/// <value>The path.</value>
public string[] Paths { get; set; }
+
+ public LibraryOptions LibraryOptions { get; set; }
}
[Route("/Library/VirtualFolders", "DELETE")]
@@ -136,6 +141,14 @@ namespace MediaBrowser.Api.Library
public bool RefreshLibrary { get; set; }
}
+ [Route("/Library/VirtualFolders/LibraryOptions", "POST")]
+ public class UpdateLibraryOptions : IReturnVoid
+ {
+ public string Id { get; set; }
+
+ public LibraryOptions LibraryOptions { get; set; }
+ }
+
/// <summary>
/// Class LibraryStructureService
/// </summary>
@@ -184,13 +197,22 @@ namespace MediaBrowser.Api.Library
return ToOptimizedSerializedResultUsingCache(result);
}
+ public void Post(UpdateLibraryOptions request)
+ {
+ var collectionFolder = (CollectionFolder)_libraryManager.GetItemById(request.Id);
+
+ collectionFolder.UpdateLibraryOptions(request.LibraryOptions);
+ }
+
/// <summary>
/// Posts the specified request.
/// </summary>
/// <param name="request">The request.</param>
public void Post(AddVirtualFolder request)
{
- _libraryManager.AddVirtualFolder(request.Name, request.CollectionType, request.Paths, request.RefreshLibrary);
+ var libraryOptions = request.LibraryOptions ?? new LibraryOptions();
+
+ _libraryManager.AddVirtualFolder(request.Name, request.CollectionType, request.Paths, libraryOptions, request.RefreshLibrary);
}
/// <summary>
@@ -214,12 +236,12 @@ namespace MediaBrowser.Api.Library
var currentPath = Path.Combine(rootFolderPath, request.Name);
var newPath = Path.Combine(rootFolderPath, request.NewName);
- if (!_fileSystem.DirectoryExists(currentPath))
+ if (!_fileSystem.DirectoryExists(currentPath))
{
throw new DirectoryNotFoundException("The media collection does not exist");
}
- if (!string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase) && _fileSystem.DirectoryExists(newPath))
+ if (!string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase) && _fileSystem.DirectoryExists(newPath))
{
throw new ArgumentException("There is already a media collection with the name " + newPath + ".");
}
@@ -234,11 +256,11 @@ namespace MediaBrowser.Api.Library
//Create an unique name
var temporaryName = Guid.NewGuid().ToString();
var temporaryPath = Path.Combine(rootFolderPath, temporaryName);
- _fileSystem.MoveDirectory(currentPath, temporaryPath);
+ _fileSystem.MoveDirectory(currentPath, temporaryPath);
currentPath = temporaryPath;
}
- _fileSystem.MoveDirectory(currentPath, newPath);
+ _fileSystem.MoveDirectory(currentPath, newPath);
}
finally
{