コード例 #1
0
        public async Task ProcessFile(BackgroundDownloadFile file)
        {
            if (!(await NativeAudioPlayer.VerifyMp3(file.Destination, true)))
            {
                LogManager.Shared.Log("Failed Download", file);
                Download(file);
                return;
            }
            Files.Remove(file.TrackId);
            if (TasksDictionary.ContainsKey(file.Id))
            {
                TasksDictionary.Remove(file.Id);
            }
            var destination = Path.Combine(Locations.MusicDir, Path.GetFileName(file.Destination));

            if (File.Exists(destination))
            {
                File.Delete(destination);
            }
            File.Move(file.Destination, destination);

            LogManager.Shared.Log("File Proccessed", file);
            await OfflineManager.Shared.TrackDownloaded(file.TrackId);

            NotificationManager.Shared.ProcDownloaderStarted();
        }
コード例 #2
0
        /// <summary>
        /// Removes the task from the storage.
        /// </summary>
        /// <param name="task">The DownloadTask.</param>
        public void UnRegisterTask(DownloadTask task)
        {
            lock (registry)
            {
                if (TasksDictionary.ContainsKey(task.DownloadItem.Enclosure.Url))
                {
                    TasksDictionary.Remove(task.DownloadItem.Enclosure.Url);
                    RemoveTask(task);
                    var disposable = task.Downloader as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
            }
            string fileName = Path.Combine(RootDir.FullName, task.TaskId + ".task");

            FileHelper.DestroyFile(fileName);
        }