Skip to content

Commit

Permalink
Revert package scanning behavior in unmanaged paths.
Browse files Browse the repository at this point in the history
This fixes issue #2691 properly by just silencing the bogus warnings and scanning as always. There is no reason in expecting or supporting the same sub directory structure as for managed paths.
  • Loading branch information
s-ludwig committed Feb 16, 2024
1 parent 85a78c0 commit e7532b3
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions source/dub/packagemanager.d
Original file line number Diff line number Diff line change
Expand Up @@ -1442,26 +1442,29 @@ package struct Location {
// Packages are stored in $ROOT/$SOMETHING/`
const pack_path = path ~ (pdir.name ~ "/");
auto packageFile = Package.findPackageFile(pack_path);
if (!packageFile.empty) {
// Deprecated unmanaged directory structure
logWarn("Package at path '%s' should be under '%s'",
pack_path.toNativeString().color(Mode.bold),
(pack_path ~ "$VERSION" ~ pdir.name).toNativeString().color(Mode.bold));
logWarn("The package will no longer be detected starting from v1.42.0");
loadInternal(pack_path, packageFile);
}

// Managed structure: $ROOT/$NAME/$VERSION/$NAME
// This is the most common code path
else {
// Iterate over versions of a package
foreach (versdir; mgr.iterateDirectory(pack_path)) {
if (!versdir.isDirectory) continue;
auto vers_path = pack_path ~ versdir.name ~ (pdir.name ~ "/");
if (!mgr.existsDirectory(vers_path)) continue;
packageFile = Package.findPackageFile(vers_path);
loadInternal(vers_path, packageFile);
if (isManaged(path)) {
if (!packageFile.empty) {
// Deprecated unmanaged directory structure
logWarn("Package at path '%s' should be under '%s'",
pack_path.toNativeString().color(Mode.bold),
(pack_path ~ "$VERSION" ~ pdir.name).toNativeString().color(Mode.bold));
logWarn("The package will no longer be detected starting from v1.42.0");
loadInternal(pack_path, packageFile);
} else {
// Managed structure: $ROOT/$NAME/$VERSION/$NAME
// This is the most common code path
// Iterate over versions of a package
foreach (versdir; mgr.iterateDirectory(pack_path)) {
if (!versdir.isDirectory) continue;
auto vers_path = pack_path ~ versdir.name ~ (pdir.name ~ "/");
if (!mgr.existsDirectory(vers_path)) continue;
packageFile = Package.findPackageFile(vers_path);
loadInternal(vers_path, packageFile);
}
}
} else {
if (!packageFile.empty)
loadInternal(pack_path, packageFile);
}
}
catch (Exception e)
Expand Down

0 comments on commit e7532b3

Please sign in to comment.