示例#1
0
        public async Task ReportSyncJobItemTransferred(string id)
        {
            var jobItem = _repo.GetJobItem(id);

            jobItem.Status   = SyncJobItemStatus.Synced;
            jobItem.Progress = 100;

            if (jobItem.RequiresConversion)
            {
                try
                {
                    File.Delete(jobItem.OutputPath);
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error deleting temporary job file: {0}", ex, jobItem.OutputPath);
                }
            }

            await _repo.Update(jobItem).ConfigureAwait(false);

            var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, _mediaEncoder());

            await processor.UpdateJobStatus(jobItem.JobId).ConfigureAwait(false);
        }
示例#2
0
        public async Task ReportSyncJobItemTransferred(string id)
        {
            var jobItem = _repo.GetJobItem(id);

            jobItem.Status   = SyncJobItemStatus.Synced;
            jobItem.Progress = 100;

            if (!string.IsNullOrWhiteSpace(jobItem.TemporaryPath))
            {
                try
                {
                    _fileSystem.DeleteDirectory(jobItem.TemporaryPath, true);
                }
                catch (DirectoryNotFoundException)
                {
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error deleting temporary job file: {0}", ex, jobItem.OutputPath);
                }
            }

            await UpdateSyncJobItemInternal(jobItem).ConfigureAwait(false);

            var processor = GetSyncJobProcessor();

            await processor.UpdateJobStatus(jobItem.JobId).ConfigureAwait(false);
        }
示例#3
0
        public async Task SyncJobItems(SyncJobItem[] items, bool enableConversion, IProgress <double> progress, CancellationToken cancellationToken)
        {
            if (items.Length > 0)
            {
                if (!SyncRegistrationInfo.Instance.IsRegistered)
                {
                    _logger.Debug("Cancelling sync job processing. Please obtain a supporter membership.");
                    return;
                }
            }

            var numComplete = 0;

            foreach (var item in items)
            {
                cancellationToken.ThrowIfCancellationRequested();

                double percentPerItem = 1;
                percentPerItem /= items.Length;
                var startingPercent = numComplete * percentPerItem * 100;

                var innerProgress = new ActionableProgress <double>();
                innerProgress.RegisterAction(p => progress.Report(startingPercent + (percentPerItem * p)));

                // Pull it fresh from the db just to make sure it wasn't deleted or cancelled while another item was converting
                var jobItem = enableConversion ? _syncRepo.GetJobItem(item.Id) : item;

                if (jobItem != null)
                {
                    var job = _syncRepo.GetJob(jobItem.JobId);
                    if (jobItem.Status != SyncJobItemStatus.Cancelled)
                    {
                        await ProcessJobItem(job, jobItem, enableConversion, innerProgress, cancellationToken).ConfigureAwait(false);
                    }

                    job = _syncRepo.GetJob(jobItem.JobId);
                    await UpdateJobStatus(job).ConfigureAwait(false);
                }

                numComplete++;
                double percent = numComplete;
                percent /= items.Length;
                progress.Report(100 * percent);
            }
        }