Skip to content

Commit

Permalink
Merge pull request #3 from ya-b/dev
Browse files Browse the repository at this point in the history
bugfix: Fixed an error caused by folders with the same name under dif…
  • Loading branch information
ya-b committed Sep 1, 2024
2 parents b02b7b2 + 9b8b0e0 commit e55bd2a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group 'io.github.ya-b'
version '0.1.3'
version '0.1.4'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -19,14 +19,14 @@ repositories {
}

dependencies {
implementation 'net.jodah:expiringmap:0.5.10'
implementation 'net.jodah:expiringmap:0.5.11'
implementation 'com.google.code.gson:gson:2.10'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'org.apache.commons:commons-compress:1.22'
implementation 'org.slf4j:slf4j-api:2.0.6'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'org.apache.commons:commons-compress:1.26.1'
implementation 'org.slf4j:slf4j-api:2.0.12'
testImplementation 'ch.qos.logback:logback-classic:1.3.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3'
}

test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ public static List<Blob> extractTar(InputStream is, Path dst) throws IOException
if (entry.isDirectory()) continue;
if (!tarArchiveIs.canReadEntryData(entry)) throw new IOException("read tar entry error");
Path itemPath = dst.resolve(FileUtils.replacePathChar(entry.getName()));
Files.createDirectories(itemPath.getParent());
Path subPath = Files.exists(itemPath) ? itemPath.resolveSibling(UUID.randomUUID().toString()) : itemPath;
Files.createDirectories(subPath.getParent());
Sha256HashOutputStream sha256HashOutputStream;
try (OutputStream os = new BufferedOutputStream(Files.newOutputStream(itemPath))) {
try (OutputStream os = new BufferedOutputStream(Files.newOutputStream(subPath))) {
sha256HashOutputStream = new Sha256HashOutputStream(os);
org.apache.commons.compress.utils.IOUtils.copyRange(tarArchiveIs, entry.getSize(), sha256HashOutputStream);
}
blobs.add(new Blob(entry.getName(), entry.getSize(), Constants.SHA256_PREFIX + sha256HashOutputStream.hash(),
() -> Files.newInputStream(itemPath)));
() -> Files.newInputStream(subPath)));
}
}
return blobs;
Expand Down

0 comments on commit e55bd2a

Please sign in to comment.