Skip to content

Commit

Permalink
bugfix: Fixed an error caused by folders with the same name under dif…
Browse files Browse the repository at this point in the history
…ferent layers.
  • Loading branch information
ya-b committed Sep 1, 2024
1 parent ec8a9a2 commit 82269c9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ maven
<dependency>
<groupId>io.github.ya-b</groupId>
<artifactId>registry-client</artifactId>
<version>0.1.3</version>
<version>0.1.4</version>
</dependency>
```
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 82269c9

Please sign in to comment.