Skip to content

Commit

Permalink
Simplify PackageManager.getPackagePath
Browse files Browse the repository at this point in the history
All callers ended up appending to the returned path,
so just do it in getPackagePath and save ourself some trouble.
  • Loading branch information
Geod24 committed Jan 15, 2024
1 parent 6860b2f commit 5f68822
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
12 changes: 3 additions & 9 deletions source/dub/packagemanager.d
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,6 @@ class PackageManager {

string gitReference = repo.ref_.chompPrefix("~");
NativePath destination = this.getPackagePath(PlacementLocation.user, name, repo.ref_);
// For libraries leaking their import path
destination ~= name;
destination.endsWithSlash = true;

foreach (p; getPackageIterator(name)) {
if (p.path == destination) {
Expand Down Expand Up @@ -724,8 +721,6 @@ class PackageManager {
{
NativePath dstpath = this.getPackagePath(dest, name, vers.toString());
ensureDirectory(dstpath);
// For libraries leaking their import path
dstpath = dstpath ~ name;

// possibly wait for other dub instance
import core.time : seconds;
Expand Down Expand Up @@ -1440,7 +1435,7 @@ package struct Location {

string versStr = vers.toString();
const lookupName = getBasePackageName(name);
const path = this.getPackagePath(lookupName, versStr) ~ (lookupName ~ "/");
const path = this.getPackagePath(lookupName, versStr);
if (!path.existsDirectory())
return null;

Expand All @@ -1461,13 +1456,12 @@ package struct Location {
* which expects their containing folder to have an exact name and use
* `importPath "../"`.
*
* Hence the final format should be `$BASE/$NAME-$VERSION/$NAME`,
* but this function returns `$BASE/$NAME-$VERSION/`
* Hence the final format returned is `$BASE/$NAME/$VERSION/$NAME`,
* `$BASE` is `this.packagePath`.
*/
NativePath getPackagePath (string name, string vers)
{
NativePath result = this.packagePath ~ name ~ vers;
NativePath result = this.packagePath ~ name ~ vers ~ name;
result.endsWithSlash = true;
return result;
}
Expand Down
2 changes: 0 additions & 2 deletions source/dub/test/base.d
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,6 @@ package class TestPackageManager : PackageManager

string gitReference = repo.ref_.chompPrefix("~");
NativePath destination = this.getPackagePath(PlacementLocation.user, name, repo.ref_);
destination ~= name;
destination.endsWithSlash = true;

foreach (p; getPackageIterator(name))
if (p.path == destination)
Expand Down

0 comments on commit 5f68822

Please sign in to comment.