Skip to content

Commit

Permalink
Avoid warnings when a package does not exist in a v3 folder
Browse files Browse the repository at this point in the history
LocalFolderUtility logs errors around missing directories as warnings. When checking all sources for a package id it is expected that the package will not exist in some cases. This change removes the extra unneeded warnings when probing folder paths.

Fixes NuGet/Home#3194
  • Loading branch information
emgarten committed Jul 22, 2016
1 parent 91abff5 commit fe6db5e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -861,14 +861,14 @@ public static IEnumerable<LocalPackageInfo> GetPackagesV3(string root, string id
// Check for package files one level deep.
DirectoryInfo rootDirectoryInfo = GetAndVerifyRootDirectory(root);

if (!rootDirectoryInfo.Exists)
var idRoot = Path.Combine(rootDirectoryInfo.FullName, id);
if (!Directory.Exists(idRoot))
{
// Directory is missing
yield break;
}

var pathResolver = new VersionFolderPathResolver(root);
var idRoot = Path.Combine(root, id);

foreach (var versionDir in GetDirectoriesSafe(idRoot, log))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public void LocalFolderUtility_GetPackagesConfigFolderPackages_All()
Assert.Equal("a.1.0.0", packages[1].Identity.ToString());
Assert.Equal("b.1.0.0", packages[2].Identity.ToString());
Assert.Equal("c.1.0.0", packages[3].Identity.ToString());
Assert.Equal(0, testLogger.Messages.Count);
}
}

Expand Down Expand Up @@ -135,6 +136,7 @@ public void LocalFolderUtility_GetPackagesConfigFolderPackages_ById()
Assert.Equal(2, packages.Count);
Assert.Equal("a.1.0.0-beta", packages[0].Identity.ToString());
Assert.Equal("a.1.0.0", packages[1].Identity.ToString());
Assert.Equal(0, testLogger.Messages.Count);
}
}

Expand Down Expand Up @@ -163,6 +165,7 @@ public void LocalFolderUtility_GetPackagesConfigFolderPackages_ById_NotFound()

// Assert
Assert.Equal(0, packages.Count);
Assert.Equal(0, testLogger.Messages.Count);
}
}

Expand Down Expand Up @@ -190,6 +193,7 @@ public void LocalFolderUtility_GetPackagesConfigFolderPackage()
Assert.True(foundA.IsNupkg);
Assert.Equal(a, foundA.GetReader().GetIdentity());
Assert.Contains("a.1.0.0.nupkg", foundA.Path);
Assert.Equal(0, testLogger.Messages.Count);
}
}

Expand Down Expand Up @@ -370,6 +374,7 @@ public void LocalFolderUtility_GetPackagesConfigFolderPackage_EmptyDir()

// Assert
Assert.Null(foundA);
Assert.Equal(0, testLogger.Messages.Count);
}
}

Expand All @@ -387,6 +392,7 @@ public void LocalFolderUtility_GetPackagesConfigFolderPackages_EmptyDir()

// Assert
Assert.Equal(0, packages.Count);
Assert.Equal(0, testLogger.Messages.Count);
}
}

Expand All @@ -404,6 +410,7 @@ public void LocalFolderUtility_GetPackagesConfigFolderPackagesWithId_EmptyDir()

// Assert
Assert.Equal(0, packages.Count);
Assert.Equal(0, testLogger.Messages.Count);
}
}

Expand Down Expand Up @@ -577,6 +584,7 @@ public void LocalFolderUtility_GetPackagesV2ReadWithV3()

// Assert
Assert.Equal(0, packages.Count());
Assert.Equal(0, testLogger.Messages.Count);
}
}

Expand Down Expand Up @@ -621,6 +629,7 @@ public async Task LocalFolderUtility_GetPackagesV3ReadWithV2()

// Assert
Assert.Equal(0, packages.Count());
Assert.Equal(0, testLogger.Messages.Count);
}
}

Expand Down Expand Up @@ -751,6 +760,7 @@ public void LocalFolderUtility_GetPackagesV2NotFoundEmptyDir()

// Assert
Assert.Equal(0, packages.Count);
Assert.Equal(0, testLogger.Messages.Count);
}
}

Expand All @@ -767,6 +777,7 @@ public void LocalFolderUtility_GetPackagesV2NotFoundMissingDir()

// Assert
Assert.Equal(0, packages.Count);
Assert.Equal(0, testLogger.Messages.Count);
}
}

Expand All @@ -783,6 +794,7 @@ public void LocalFolderUtility_GetPackagesByIdV2NotFoundEmptyDir()

// Assert
Assert.Equal(0, packages.Count);
Assert.Equal(0, testLogger.Messages.Count);
}
}

Expand All @@ -799,6 +811,7 @@ public void LocalFolderUtility_GetPackagesByIdV2NotFoundMissingDir()

// Assert
Assert.Equal(0, packages.Count);
Assert.Equal(0, testLogger.Messages.Count);
}
}

Expand Down Expand Up @@ -898,6 +911,7 @@ public void LocalFolderUtility_GetPackagesV3NotFoundEmptyDir()

// Assert
Assert.Equal(0, packages.Count);
Assert.Equal(0, testLogger.Messages.Count);
}
}

Expand All @@ -914,6 +928,7 @@ public void LocalFolderUtility_GetPackagesV3NotFoundMissingDir()

// Assert
Assert.Equal(0, packages.Count);
Assert.Equal(0, testLogger.Messages.Count);
}
}

Expand All @@ -930,6 +945,7 @@ public void LocalFolderUtility_GetPackagesByIdV3NotFoundEmptyDir()

// Assert
Assert.Equal(0, packages.Count);
Assert.Equal(0, testLogger.Messages.Count);
}
}

Expand All @@ -946,6 +962,7 @@ public void LocalFolderUtility_GetPackagesByIdV3NotFoundMissingDir()

// Assert
Assert.Equal(0, packages.Count);
Assert.Equal(0, testLogger.Messages.Count);
}
}

Expand Down

0 comments on commit fe6db5e

Please sign in to comment.