예제 #1
0
 private void ResetProgress()
 {
     SongsDownloaded.Clear();
     SongsToDownload.Clear();
     IsActive = true;
     IsError  = false;
 }
예제 #2
0
        private void Synchronize(IList <Track> tracks, string clientId, string directoryPath, bool deleteRemovedSongs)
        {
            // determine which tracks should be downloaded
            SongsToDownload = DetermineTracksToDownload(directoryPath, tracks);

            // determine which tracks should be deleted
            if (deleteRemovedSongs)
            {
                DeleteRemovedTrack(directoryPath, tracks);
            }

            // download the relevant tracks
            IList <Track> songsDownloaded = DownloadSongs(SongsToDownload, clientId);

            // update the manifest
            UpdateSyncManifest(songsDownloaded, directoryPath);

            // validation
            if (songsDownloaded.Count != SongsToDownload.Count && IsActive)
            {
                IsError = true;
                throw new Exception(
                          "Some tracks failed to download. You might need to try a few more times before they can download correctly. " +
                          "The following tracks were not downloaded:" + Environment.NewLine +
                          string.Join(Environment.NewLine, SongsToDownload.Except(SongsDownloaded).Select(x => "Title: " + x.Title + ", Artist: " + x.Artist))
                          );
            }
        }