From 911d4c3e91bfa0f6c30bad2bf4263a45921e464e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Fri, 16 Feb 2024 20:42:40 +0100 Subject: [PATCH] Properly fix issue #2691 by reverting to the original scanning behavior. Reverts to the scanning/warning behavior that was in place before the warnings for the new package directory structure were implemented. --- source/dub/packagemanager.d | 51 ++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/source/dub/packagemanager.d b/source/dub/packagemanager.d index 7a8cbf68b..15b990958 100644 --- a/source/dub/packagemanager.d +++ b/source/dub/packagemanager.d @@ -1438,30 +1438,41 @@ package struct Location { logDebug("iterating dir %s entry %s", path.toNativeString(), pdir.name); if (!pdir.isDirectory) continue; - // Old / flat directory structure, used in non-standard path - // 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 if (mgr.isManagedPath(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); + if (mgr.isManagedPath(path)) { + // Old / flat directory structure, used in non-standard path + // Packages are stored in $ROOT/$SOMETHING/` + 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 { + // Unmanaged directories (dub add-path) are always stored as a + // flat list of packages, as these are the working copies managed + // by the user. The nested structure should not be supported, + // even optionally, because that would lead to bogus "no package + // file found" errors in case the internal directory structure + // accidentally matches the $NAME/$VERSION/$NAME scheme + if (!packageFile.empty) + loadInternal(pack_path, packageFile); } } catch (Exception e)