diff --git a/source/dub/commandline.d b/source/dub/commandline.d index bb816cd..69475a5 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -189,7 +189,7 @@ // make the CWD package available so that for example sub packages can reference their // parent package. - try dub.packageManager.getTemporaryPackage(Path(root_path)); + try dub.packageManager.getOrLoadPackage(Path(root_path)); catch (Exception e) { logDiagnostic("No package found in current working directory."); } } diff --git a/source/dub/dub.d b/source/dub/dub.d index 3b468b9..b70c223 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -182,7 +182,7 @@ foreach (p; m_project.selections.selectedPackages) { auto dep = m_project.selections.getSelectedVersion(p); if (!dep.path.empty) { - if (m_packageManager.getTemporaryPackage(dep.path)) continue; + if (m_packageManager.getOrLoadPackage(dep.path)) continue; } else { if (m_packageManager.getPackage(p, dep.version_)) continue; foreach (ps; m_packageSuppliers) { @@ -209,7 +209,7 @@ foreach (p, ver; versions) { assert(!p.canFind(":"), "Resolved packages contain a sub package!?: "~p); Package pack; - if (!ver.path.empty) pack = m_packageManager.getTemporaryPackage(ver.path); + if (!ver.path.empty) pack = m_packageManager.getOrLoadPackage(ver.path); else pack = m_packageManager.getBestPackage(p, ver); FetchOptions fetchOpts; fetchOpts |= (options & UpgradeOptions.preRelease) != 0 ? FetchOptions.usePrerelease : FetchOptions.none; diff --git a/source/dub/packagemanager.d b/source/dub/packagemanager.d index 365a3f8..77c5df9 100644 --- a/source/dub/packagemanager.d +++ b/source/dub/packagemanager.d @@ -154,6 +154,7 @@ Package getOrLoadPackage(Path path) { + path.endsWithSlash = true; foreach (p; getPackageIterator()) if (!p.parentPackage && p.path == path) return p; @@ -503,38 +504,6 @@ logInfo("Unregistered package: %s (version: %s)", name, ver); } - Package getTemporaryPackage(Path path, Version ver) - { - foreach (p; m_temporaryPackages) - if (p.path == path) { - enforce(p.ver == ver, format("Package in %s is refrenced with two conflicting versions: %s vs %s", path.toNativeString(), p.ver, ver)); - return p; - } - - try { - auto pack = new Package(path); - enforce(pack.name.length, "The package has no name, defined in: " ~ path.toString()); - pack.ver = ver; - addPackages(m_temporaryPackages, pack); - return pack; - } catch (Exception e) { - logDiagnostic("Error loading package at %s: %s", path.toNativeString(), e.toString().sanitize); - throw new Exception(format("Failed to add temporary package at %s: %s", path.toNativeString(), e.msg)); - } - } - - Package getTemporaryPackage(Path path) - { - foreach (p; m_temporaryPackages) - if (p.path == path) - return p; - - auto pack = new Package(path); - enforce(pack.name.length, "The package has no name, defined in: " ~ path.toString()); - addPackages(m_temporaryPackages, pack); - return pack; - } - /// For the given type add another path where packages will be looked up. void addSearchPath(Path path, LocalPackageType type) { @@ -624,7 +593,7 @@ try foreach( pdir; iterateDirectory(path) ){ logDebug("iterating dir %s entry %s", path.toNativeString(), pdir.name); if( !pdir.isDirectory ) continue; - auto pack_path = path ~ pdir.name; + auto pack_path = path ~ (pdir.name ~ "/"); if (!Package.isPackageAt(pack_path)) continue; Package p; try { diff --git a/source/dub/project.d b/source/dub/project.d index c1916d9..88115ab 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -203,7 +203,7 @@ Path path = vspec.path; if (!path.absolute) path = pack.path ~ path; logDiagnostic("Adding local %s", path); - p = m_packageManager.getTemporaryPackage(path); + p = m_packageManager.getOrLoadPackage(path); enforce(p.name == name, format("Path based dependency %s is referenced with a wrong name: %s vs. %s", path.toNativeString(), name, p.name)); }