Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Commit

Permalink
Ignore unlisted packages
Browse files Browse the repository at this point in the history
  • Loading branch information
troydai committed Feb 20, 2015
1 parent 530ddc4 commit 02d3bc9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ await ConcurrencyUtilities.ExecuteWithFileLocked(result.CacheFileName, async _ =
}
}
// If the desitnation file doesn't exist, we can safely perform moving operation.
// If the destination file doesn't exist, we can safely perform moving operation.
// Otherwise, moving operation will fail.
if (!File.Exists(result.CacheFileName))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public class NuGetv2Feed : IPackageFeed
private static readonly XName _xnameProperties = XName.Get("properties", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
private static readonly XName _xnameId = XName.Get("Id", "http://schemas.microsoft.com/ado/2007/08/dataservices");
private static readonly XName _xnameVersion = XName.Get("Version", "http://schemas.microsoft.com/ado/2007/08/dataservices");
private static readonly XName _xnamePublish = XName.Get("Published", "http://schemas.microsoft.com/ado/2007/08/dataservices");

// An unlisted package's publish time must be 1900-01-01T00:00:00.
private static readonly DateTime _unlistedPublishedTime = new DateTime(1900, 1, 1, 0, 0, 0);

private readonly string _baseUri;
private readonly Reports _reports;
Expand Down Expand Up @@ -89,7 +93,7 @@ public async Task<IEnumerable<PackageInfo>> FindPackagesByIdAsyncCore(string id)
var page = 1;
while (true)
{
// TODO: Pages for a package Id are cahced separately.
// TODO: Pages for a package Id are cached separately.
// So we will get inaccurate data when a page shrinks.
// However, (1) In most cases the pages grow rather than shrink;
// (2) cache for pages is valid for only 30 min.
Expand All @@ -104,7 +108,8 @@ public async Task<IEnumerable<PackageInfo>> FindPackagesByIdAsyncCore(string id)

var result = doc.Root
.Elements(_xnameEntry)
.Select(x => BuildModel(id, x));
.Select(x => BuildModel(id, x))
.Where(x => x != null);

results.AddRange(result);

Expand Down Expand Up @@ -170,6 +175,16 @@ public PackageInfo BuildModel(string id, XElement element)
var idElement = properties.Element(_xnameId);
var titleElement = element.Element(_xnameTitle);

var publishElement = properties.Element(_xnamePublish);
if (publishElement != null)
{
DateTime publishDate;
if (DateTime.TryParse(publishElement.Value, out publishDate) && (publishDate == _unlistedPublishedTime))
{
return null;
}
}

return new PackageInfo
{
// If 'Id' element exist, use its value as accurate package Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public RestoreCommand(IApplicationEnvironment env)
public string PackageFolder { get; set; }
public string GlobalJsonFile { get; set; }

public string RestorePackageId { get; set; }
public string RestorePackageId { get; set; }
public string RestorePackageVersion { get; set; }

public string AppInstallPath { get; private set; }
Expand Down

0 comments on commit 02d3bc9

Please sign in to comment.