public async Task RemovePackageAsync(string packageId, string packageVersion) { if (packageId == null) { throw new ArgumentNullException("packageId"); } if (packageVersion == null) { throw new ArgumentNullException("packageVersion"); } await BlogFilesContainer.GetBlockBlobReference(GetPackageKey(packageId, packageVersion)).DeleteAsync(); var cachedPackage = Cache[packageId] as IWebPackage; if (cachedPackage != null && cachedPackage.Version == SemanticVersion.Parse(packageVersion)) { Cache.Remove(packageId); // Load the latest package to Cache var packages = BlogFilesContainer.ListBlobs().OfType <CloudBlockBlob>().Select(SafeReadZipPackage).Where(package => package != null).Where(p => p.Id == packageId); if (packages.Any()) { var latestPackage = packages.MaxBy(p => p.Version); if (latestPackage != null) { AddToCache(latestPackage); } } } }
public IWebPackage GetPackage(string id, string version) { if (Cache[id] != null && ((IWebPackage)Cache[id]).Version == new SemanticVersion(version)) { return(Cache[id] as IWebPackage); } return(SafeReadZipPackage(BlogFilesContainer.GetBlockBlobReference(GetPackageKey(id, version)))); }
public async Task AddPackageAsync(IPackage package) { if (package == null) { throw new ArgumentNullException("package"); } if (package is ZipPackage) { (package as ZipPackage).Published = DateTimeOffset.Now; } var blockBlobReference = BlogFilesContainer.GetBlockBlobReference(GetPackageKey(package)); await blockBlobReference.UploadFromStreamAsync(package.GetStream()); AddToCache(new WebZipPackage(package.GetStream(), blockBlobReference.Uri)); }