Skip to content

Commit

Permalink
packagesuppliers/filesystem.d: Only look for versions of package_id
Browse files Browse the repository at this point in the history
When looking for versions of a package don't include any files that
aren't versions of the queried package.

If a directory contains the files botan-1.zip and botan-math-2.zip
the current implementation would report both 1 and math-2 as
candidates followed by an error that math-2 is not a valid version.

Signed-off-by: Andrei Horodniceanu <[email protected]>
  • Loading branch information
the-horo committed Dec 19, 2023
1 parent afaf10a commit 330d7d5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion source/dub/packagesuppliers/filesystem.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@ class FileSystemPackageSupplier : PackageSupplier {
import std.algorithm.sorting : sort;
import std.file : dirEntries, DirEntry, SpanMode;
import std.conv : to;
import dub.semver : isValidVersion;
Version[] ret;
foreach (DirEntry d; dirEntries(m_path.toNativeString(), package_id~"*", SpanMode.shallow)) {
NativePath p = NativePath(d.name);
logDebug("Entry: %s", p);
enforce(to!string(p.head)[$-4..$] == ".zip");
auto vers = p.head.name[package_id.length+1..$-4];
if (!isValidVersion(vers)) {
logDebug("Ignoring entry '%s' because it isn't a version of package '%s'", p, package_id);
continue;
}
logDebug("Entry: %s", p);
logDebug("Version: %s", vers);
ret ~= Version(vers);
}
Expand Down

0 comments on commit 330d7d5

Please sign in to comment.