Provides access to a disk-based cache of Feeds that were downloaded via HTTP(S).

Local feed files are simply passed through this cache.

Once a feed has been added to this cache it is considered trusted (signatures are not checked again).

Inheritance: IFeedCache
Exemplo n.º 1
0
        /// <summary>
        /// Creates an <see cref="IFeedCache"/> instance that uses the default cache location in the user profile.
        /// </summary>
        /// <param name="openPgp">Provides access to an encryption/signature system compatible with the OpenPGP standard.</param>
        /// <exception cref="IOException">A problem occurred while creating a directory.</exception>
        /// <exception cref="UnauthorizedAccessException">Creating a directory is not permitted.</exception>
        public static IFeedCache CreateDefault(IOpenPgp openPgp)
        {
            var cache = new DiskFeedCache(Locations.GetCacheDirPath("0install.net", machineWide: false, resource: "interfaces"), openPgp);

            // Note: Recreate memory-caching layer for each call to prevent long-running caches from getting out of sync with disk because of changes made by other processes
            return new MemoryFeedCache(cache);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates an <see cref="IFeedCache"/> instance that uses the default cache location in the user profile.
        /// </summary>
        /// <param name="openPgp">Provides access to an encryption/signature system compatible with the OpenPGP standard.</param>
        /// <exception cref="IOException">A problem occurred while creating a directory.</exception>
        /// <exception cref="UnauthorizedAccessException">Creating a directory is not permitted.</exception>
        public static IFeedCache CreateDefault(IOpenPgp openPgp)
        {
            var cache = new DiskFeedCache(Locations.GetCacheDirPath("0install.net", machineWide: false, resource: "interfaces"), openPgp);

            // Note: Recreate memory-caching layer for each call to prevent long-running caches from getting out of sync with disk because of changes made by other processes
            return(new MemoryFeedCache(cache));
        }
Exemplo n.º 3
0
        public override void SetUp()
        {
            base.SetUp();

            // Create a temporary cache
            _tempDir = new TemporaryDirectory("0install-unit-tests");
            _cache = new DiskFeedCache(_tempDir, new Mock<IOpenPgp>().Object);

            // Add some dummy feeds to the cache
            _feed1 = FeedTest.CreateTestFeed();
            _feed1.Uri = FeedTest.Test1Uri;
            _feed1.SaveXml(Path.Combine(_tempDir, _feed1.Uri.Escape()));

            var feed2 = FeedTest.CreateTestFeed();
            feed2.Uri = FeedTest.Test2Uri;
            feed2.SaveXml(Path.Combine(_tempDir, feed2.Uri.Escape()));
            File.WriteAllText(Path.Combine(_tempDir, "http_invalid"), "");
        }
Exemplo n.º 4
0
        public void DownloadPackage([NotNull] string fastPackageReference, [NotNull] string location)
        {
            Directory.CreateDirectory(location);
            this.GetEmbedded("import.bat").CopyToFile(Path.Combine(location, "import.bat"));

            FeedCache = new DiskFeedCache(Path.Combine(location, "interfaces"), OpenPgp);
            Store = new DirectoryStore(Path.Combine(location, "implementations"), useWriteProtection: false);
            FeedManager.Refresh = true;

            var requirements = ParseReference(fastPackageReference);
            var selections = Solve(requirements);
            Fetcher.Fetch(SelectionsManager.GetUncachedImplementations(selections));

            SelfUpdateCheck();
        }