コード例 #1
0
        public async Task CheckLibrary(LibraryCheckFlags checkFlags, IOperationProgress progress, Action <LibraryInconsistency> inconsistenciesHandler, CancellationToken cancellationToken)
        {
            var activeDiscs = DiscLibrary.Discs.Where(d => !d.IsDeleted).ToList();

            if (checkFlags.HasFlag(LibraryCheckFlags.CheckDiscsConsistency))
            {
                await discConsistencyChecker.CheckDiscsConsistency(activeDiscs, inconsistenciesHandler, cancellationToken);
            }

            if (checkFlags.HasFlag(LibraryCheckFlags.CheckStorageConsistency))
            {
                var activeFolders = DiscLibrary.Folders.Where(f => !f.IsDeleted);

                await storageRepository.CheckStorage(checkFlags, activeFolders, activeDiscs, progress, inconsistenciesHandler, cancellationToken);
            }
        }
コード例 #2
0
        private void CheckDiscsData(IReadOnlyCollection <DiscModel> discs, LibraryCheckFlags checkFlags, HashSet <string> visitedFolders,
                                    HashSet <string> visitedFiles, IOperationProgress progress, Action <LibraryInconsistency> inconsistenciesHandler)
        {
            progress.SetOperationCost(discs.SelectMany(d => d.ActiveSongs).Count());

            var checkContent = checkFlags.HasFlag(LibraryCheckFlags.CheckContentConsistency);

            foreach (var disc in discs)
            {
                var discFolderPath = storageOrganizer.GetDiscFolderPath(disc);
                CheckStorageFolder(discFolderPath, inconsistenciesHandler);
                visitedFolders.Add(fileStorage.GetFullPath(discFolderPath));

                foreach (var song in disc.ActiveSongs)
                {
                    var songPath = storageOrganizer.GetSongFilePath(song);
                    CheckStorageFile(songPath, checkContent, song.Size.Value, song.Checksum.Value, inconsistenciesHandler);

                    visitedFiles.Add(fileStorage.GetFullPath(songPath));

                    if (checkFlags.HasFlag(LibraryCheckFlags.CheckSongTagsConsistency))
                    {
                        CheckSongTags(song, inconsistenciesHandler);
                    }

                    progress.IncrementOperationProgress();
                }

                foreach (var image in disc.Images)
                {
                    var imagePath = storageOrganizer.GetDiscImagePath(image);
                    CheckStorageFile(imagePath, checkContent, image.Size, image.Checksum, inconsistenciesHandler);

                    visitedFiles.Add(fileStorage.GetFullPath(imagePath));
                }
            }
        }