aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/Library/FileOrganizationService.cs
diff options
context:
space:
mode:
authorsoftworkz <softworkz@hotmail.com>2016-08-19 03:00:04 +0200
committersoftworkz <softworkz@hotmail.com>2016-08-20 01:03:30 +0200
commit751febc1de65c9f2811deca66d093503968dd514 (patch)
tree37474c3c4822f2a112b13b2c5cd46dd5164d94f6 /MediaBrowser.Api/Library/FileOrganizationService.cs
parentd1da8f4449580dd642ae71580e9c40cab8aedbe3 (diff)
Auto-Organize: Async operation and instant feedback UI (reworked)
This commit includes changes to enable and stabilize asyncronous operation in the auto-organize area. Here are the key points: - The auto-organize correction dialog is now closed (almost) instantly. This means that the user does not have to wait until the file copy/move operation is completed in order to continue. (even with local HDs the copy/move process can take several minutes or even much longer with network destination). - This commit also implements locking of files to be organized in order to prevent parallel processing of the same item. In effect, there can be 2 or more manual organization operations active even while the normal auto-organization task is running without causing any problems - The items that are currently being processed are indicated as such in the log with an orange color and a spinner graphic - The client display is refreshed through websocket messages - A side effect of this is that other clients showing the auto-organize log at the same time are always up-to-date as well
Diffstat (limited to 'MediaBrowser.Api/Library/FileOrganizationService.cs')
-rw-r--r--MediaBrowser.Api/Library/FileOrganizationService.cs14
1 files changed, 8 insertions, 6 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)