示例#1
0
        public async Task UpdateSong(SongModel song, Action <SongModel> updateAction, CancellationToken cancellationToken)
        {
            var currentSong = song.CloneShallow();

            updateAction(song);

            if (!song.IsDeleted)
            {
                if (song.TreeTitle != currentSong.TreeTitle)
                {
                    await storageRepository.UpdateSongTreeTitle(currentSong, song, cancellationToken);
                }

                // Checking if storage data (tags) must be updated.
                if (song.TrackNumber != currentSong.TrackNumber || song.Title != currentSong.Title ||
                    !artistsComparer.Equals(song.Artist, currentSong.Artist) || !genresComparer.Equals(song.Genre, currentSong.Genre))
                {
                    await storageRepository.UpdateSong(song, cancellationToken);
                }
            }

            // Update in repository should be performed after update in the storage, because later updates song checksum.
            await songsRepository.UpdateSong(song, cancellationToken);
        }