protected override async Task OnRun()
        {
            var position = 0;

            using (var task = new SingletonReentrantTask(this, ComponentSlots.Database, SingletonReentrantTask.PRIORITY_LOW, async cancellationToken =>
            {
                var metaDataSource = this.MetaDataSourceFactory.Create();
                foreach (var libraryItem in this.LibraryItems)
                {
                    this.Description = Path.GetFileName(libraryItem.FileName);
                    this.Position = position;

                    if (!File.Exists(libraryItem.FileName))
                    {
                        Logger.Write(this, LogLevel.Debug, "File \"{0}\" no longer exists: Cannot refresh.", libraryItem.FileName);
                        continue;
                    }

                    var metaDatas = await metaDataSource.GetMetaData(libraryItem.FileName).ConfigureAwait(false);
                    MetaDataItem.Update(metaDatas, libraryItem.MetaDatas, null);

                    await this.WriteLibraryMetaData(libraryItem).ConfigureAwait(false);

                    libraryItem.Status = LibraryItemStatus.Import;
                    await LibraryTaskBase.UpdateLibraryItem(this.Database, libraryItem).ConfigureAwait(false);

                    position++;
                }
            }))
            {
                await task.Run().ConfigureAwait(false);
            }
        }
示例#2
0
        public static IEnumerable <string> UpdatePlaylistCache(IPlaylistCache playlistCache, IEnumerable <LibraryItem> libraryItems, IEnumerable <string> names)
        {
            var result = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var libraryItem in libraryItems)
            {
                var playlistItems = default(PlaylistItem[]);
                if (playlistCache.TryGetItemsByLibraryId(libraryItem.Id, out playlistItems))
                {
                    result.AddRange(MetaDataItem.Update(libraryItem, playlistItems, names));
                }
            }
            return(result);
        }
示例#3
0
        public static IEnumerable <string> UpdatePlaylistCache(IPlaylistCache playlistCache, IEnumerable <PlaylistItem> playlistItems, IEnumerable <string> names)
        {
            var result = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var playlistItem in playlistItems)
            {
                var cachedPlaylistItem = default(PlaylistItem);
                if (playlistCache.TryGetItemById(playlistItem.Id, out cachedPlaylistItem))
                {
                    if (!object.ReferenceEquals(playlistItem, cachedPlaylistItem))
                    {
                        result.AddRange(MetaDataItem.Update(playlistItem, cachedPlaylistItem, names));
                    }
                }
            }
            return(result);
        }
示例#4
0
        public static IEnumerable <string> UpdateLibraryCache(ILibraryCache libraryCache, IEnumerable <LibraryItem> libraryItems, IEnumerable <string> names)
        {
            var result = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var libraryItem in libraryItems)
            {
                var cachedLibraryItem = default(LibraryItem);
                if (libraryCache.TryGetItem(libraryItem.Id, out cachedLibraryItem))
                {
                    if (!object.ReferenceEquals(libraryItem, cachedLibraryItem))
                    {
                        result.AddRange(MetaDataItem.Update(libraryItem, cachedLibraryItem, names));
                    }
                }
            }
            return(result);
        }
示例#5
0
        public static IEnumerable <string> UpdateLibraryCache(ILibraryCache libraryCache, IEnumerable <PlaylistItem> playlistItems, IEnumerable <string> names)
        {
            var result = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var playlistItem in playlistItems)
            {
                if (!playlistItem.LibraryItem_Id.HasValue)
                {
                    continue;
                }
                var libraryItem = default(LibraryItem);
                if (libraryCache.TryGetItem(playlistItem.LibraryItem_Id.Value, out libraryItem))
                {
                    result.AddRange(MetaDataItem.Update(playlistItem, libraryItem, names));
                }
            }
            return(result);
        }