示例#1
0
        public IEnumerable <PackageCleanResult> Clean(IEnumerable <IPackageInfo> packagesToKeep)
        {
            packagesToKeep = packagesToKeep.ToList();
            var packagesToRemove = Packages.Where(x => !packagesToKeep.Contains(x.Package)).ToList();

            foreach (var packageInfo in packagesToRemove)
            {
                if (!Packages.Contains(packageInfo))
                {
                    throw new ArgumentException("Supplied packageInfo must belong to the FolderRepository.", "packageInfo");
                }

                if (packageInfo.CacheDirectory.TryDelete())
                {
                    Packages.Remove(packageInfo);

                    BasePath.GetFile(packageInfo.Package.FullName + ".wrap").Delete();
                    yield return(new PackageCleanResult(packageInfo.Package, true));
                }
                else
                {
                    yield return(new PackageCleanResult(packageInfo.Package, false));
                }
            }
        }
示例#2
0
        public IPackageInfo Publish(string packageFileName, Stream packageStream)
        {
            packageFileName = PackageNameUtility.NormalizeFileName(packageFileName);

            var wrapFile = BasePath.GetFile(packageFileName);

            if (wrapFile.Exists)
            {
                return(null);
            }

            using (var file = wrapFile.OpenWrite())
                StreamExtensions.CopyTo(packageStream, file);

            var newPackageCacheDir = _rootCacheDirectory.GetDirectory(wrapFile.NameWithoutExtension);
            var newPackage         = new CachedZipPackage(this, wrapFile, newPackageCacheDir);

            Packages.Add(new PackageLocation(newPackageCacheDir, newPackage));
            return(newPackage);
        }
示例#3
0
        void RefreshLockFiles()
        {
            if (!_canLock)
            {
                return;
            }
            _lockFile = BasePath.Files("*.lock").Where(x => x.Name.StartsWith("packages.")).OrderBy(x => x.Name.Length).FirstOrDefault()
                        ?? BasePath.GetFile("packages.lock");
            _lockFileUri = new Uri(ConstantUris.URI_BASE, UriKind.Absolute).Combine(new Uri(_lockFile.Name, UriKind.Relative));
            if (_lockFile.Exists == false)
            {
                return;
            }

            var lockedPackageInfo = new DefaultConfigurationManager(BasePath).Load <LockedPackages>(_lockFileUri)
                                    .Lock;
            var lockedPackages = lockedPackageInfo.Select(
                locked => _packageLoader.Packages.Single(package => locked.Name.EqualsNoCase(package.Package.Name) &&
                                                         locked.Version == package.Package.Version).Package);

            LockedPackages = lockedPackages.ToLookup(x => string.Empty);
        }