Пример #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);
        }
Пример #2
0
        public async Task UpdateDisc(DiscModel disc, Action <DiscModel> updateAction, CancellationToken cancellationToken)
        {
            var currentDisc = disc.CloneShallow();

            updateAction(disc);

            if (!disc.IsDeleted && disc.TreeTitle != currentDisc.TreeTitle)
            {
                await storageRepository.UpdateDiscTreeTitle(currentDisc, disc, cancellationToken);
            }

            if (disc.AlbumTitle != currentDisc.AlbumTitle || disc.Year != currentDisc.Year)
            {
                foreach (var song in disc.ActiveSongs)
                {
                    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);
                }
            }

            await discsRepository.UpdateDisc(disc, cancellationToken);
        }