Ejemplo n.º 1
0
        /// <inheritdoc/>
        public void Add(FeedUri feedUri, byte[] data)
        {
            #region Sanity checks
            if (feedUri == null)
            {
                throw new ArgumentNullException("feedUri");
            }
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            #endregion

            // Add to underlying cache
            _backingCache.Add(feedUri, data);

            // Add to memory cache (replacing existing old versions)
            var feed = XmlStorage.LoadXml <Feed>(new MemoryStream(data));
            feed.Normalize(feedUri);

            string key = feedUri.Escape();
            lock (_feedDictionary)
            {
                _feedDictionary.Remove(key);
                _feedDictionary.Add(key, feed);
            }
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        public void ImportFeed(string path, FeedUri uri, FeedUri mirrorUrl = null)
        {
            #region Sanity checks
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }
            #endregion

            if (uri.IsFile)
            {
                throw new UriFormatException(Resources.FeedUriLocal);
            }
            Log.Debug("Importing feed " + uri.ToStringRfc() + " from: " + path);

            var data = File.ReadAllBytes(path);

            var newSignature = _trustManager.CheckTrust(data, uri, mirrorUrl);
            DetectAttacks(data, uri, newSignature);

            // Add to cache and remember time
            _feedCache.Add(uri, data);
            var preferences = FeedPreferences.LoadForSafe(uri);
            preferences.LastChecked = DateTime.UtcNow;
            preferences.Normalize();
            preferences.SaveFor(uri);
        }
Ejemplo n.º 3
0
        private void AddToCache(byte[] data, FeedUri feedUri)
        {
            _feedCache.Add(feedUri, data);

            var preferences = FeedPreferences.LoadForSafe(feedUri);

            preferences.LastChecked = DateTime.UtcNow;
            preferences.Normalize();
            preferences.SaveFor(feedUri);
        }