public async Task <PackageInfo> UploadPackageVersion(string apiKey = null) { PackageInfo packageInfo = null; lock (ExistingPackagesLock) { var pushablePackageInfos = Packages.Where(p => p.CanUseApiKeyToPushNewVersion(apiKey)); packageInfo = pushablePackageInfos .GroupBy(p => p.Id) .Where(pr => pr.Count() > 1) .Select(pr => pr.Skip(1)) .SelectMany(pr => pr) .LastOrDefault(p => p.WasUploadedByApiKey(apiKey)); if (packageInfo != null) { return(packageInfo); } packageInfo = pushablePackageInfos.LastOrDefault(); } if (packageInfo == null) { packageInfo = await PackageInfo.CreateForUpload(this, GetApiKeyWithSameOwnerThatCanUpload(apiKey)); } return(await packageInfo.PushNewVersion(this, apiKey)); }
public async Task <PackageInfo> UnlistPackage(string apiKey = null) { PackageInfo packageInfo = null; lock (ExistingPackagesLock) { packageInfo = Packages.LastOrDefault(p => p.WasUnlistedByApiKey(apiKey)); if (packageInfo != null) { return(packageInfo); } packageInfo = Packages.LastOrDefault(p => p.Listed && p.CanUseApiKeyToPushNewVersion(apiKey)); } if (packageInfo == null) { packageInfo = await PackageInfo.CreateForUpload(this, GetApiKeyWithSameOwnerThatCanUpload(apiKey)); } await packageInfo.Unlist(this, apiKey); return(packageInfo); }
public async Task FailToUnlistPackage(string apiKey = null) { PackageInfo packageInfo = null; lock (ExistingPackagesLock) { packageInfo = Packages.LastOrDefault(p => p.HasSameOwnerAsApiKey(apiKey)); } if (packageInfo == null) { packageInfo = await PackageInfo.CreateForUpload(this, GetApiKeyWithSameOwnerThatCanUpload(apiKey)); } await packageInfo.FailToUnlist(this, apiKey); }
public async Task <PackageInfo> UploadPackage(string apiKey = null) { PackageInfo packageInfo = null; lock (ExistingPackagesLock) { packageInfo = Packages.FirstOrDefault(p => p.WasUploadedByApiKey(apiKey)); } if (packageInfo == null) { packageInfo = await PackageInfo.CreateForUpload(this, apiKey); } return(packageInfo); }