Skip to content

Commit

Permalink
Trivial: Slightly simplify PackageManager.store
Browse files Browse the repository at this point in the history
  • Loading branch information
Geod24 committed Jan 26, 2024
1 parent ef0bf93 commit 80c537e
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions source/dub/packagemanager.d
Original file line number Diff line number Diff line change
Expand Up @@ -787,18 +787,12 @@ class PackageManager {
logDebug("Placing package '%s' version '%s' to location '%s' from file '%s'",
name, vers, destination.toNativeString(), src.toNativeString());

if( existsFile(destination) ){
throw new Exception(format("%s (%s) needs to be removed from '%s' prior placement.",
name, vers, destination));
}

// open zip file
ZipArchive archive;
{
logDebug("Opening file %s", src);
archive = new ZipArchive(readFile(src));
}
enforce(!existsFile(destination),

Check warning on line 790 in source/dub/packagemanager.d

View check run for this annotation

Codecov / codecov/patch

source/dub/packagemanager.d#L790

Added line #L790 was not covered by tests
"%s (%s) needs to be removed from '%s' prior placement."
.format(name, vers, destination));

Check warning on line 792 in source/dub/packagemanager.d

View check run for this annotation

Codecov / codecov/patch

source/dub/packagemanager.d#L792

Added line #L792 was not covered by tests

logDebug("Opening file %s", src);
ZipArchive archive = new ZipArchive(readFile(src));

Check warning on line 795 in source/dub/packagemanager.d

View check run for this annotation

Codecov / codecov/patch

source/dub/packagemanager.d#L794-L795

Added lines #L794 - L795 were not covered by tests
logDebug("Extracting from zip.");

// In a GitHub zip, the actual contents are in a sub-folder
Expand Down Expand Up @@ -842,7 +836,7 @@ class PackageManager {
auto dst_path = destination ~ cleanedPath;

logDebug("Creating %s", cleanedPath);
if( dst_path.endsWithSlash ){
if (dst_path.endsWithSlash) {

Check warning on line 839 in source/dub/packagemanager.d

View check run for this annotation

Codecov / codecov/patch

source/dub/packagemanager.d#L839

Added line #L839 was not covered by tests
ensureDirectory(dst_path);
} else {
ensureDirectory(dst_path.parentPath);
Expand Down

0 comments on commit 80c537e

Please sign in to comment.