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)); } } }
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); }
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); }