Skip to content

Commit

Permalink
create folders before native 7z extraction
Browse files Browse the repository at this point in the history
This fixes an otherwise unintelligible error of the native backend in
case archive entries are extracted when their parent folders do not yet exist:

    HRESULT: 0x1 (FALSE)
  • Loading branch information
memo33 committed Mar 22, 2024
1 parent 45dd369 commit 4d9e28d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Unreleased]
### Fixed
- The path to the file `sc4pac.bat` may now contain spaces.
- an issue when extracting 7zip files or exe installers containing multiple folders


## [0.4.0] - 2024-03-16
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/sc4pac/extractor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ object Extractor {
if (extractAskMode != SZ.ExtractAskMode.EXTRACT)
null
else {
os.makeDir.all(getPath(index) / os.up) // prepares extraction (we know that entry refers to a file, not a directory)
val out = java.nio.file.Files.newOutputStream(getPath(index).toNIO, options(overwrite)*)
this.index = index
this.out = out
Expand All @@ -138,9 +139,7 @@ object Extractor {
}
}

def prepareOperation(extractAskMode: SZ.ExtractAskMode): Unit = {
os.makeDir.all(getPath(index) / os.up) // prepares extraction (we know that entry refers to a file, not a directory)
}
def prepareOperation(extractAskMode: SZ.ExtractAskMode): Unit = {}

def setOperationResult(extractOperationResult: SZ.ExtractOperationResult): Unit = {
var success = true
Expand Down Expand Up @@ -267,6 +266,7 @@ class Extractor(logger: Logger) {
extractByPredicate(archive, destination, recipe.accepts, overwrite = true, flatten = false, fallbackFilename)
// additionally, extract jar files contained in the zip file to a temporary location
for (Extractor.JarExtraction(jarsDir) <- jarExtractionOpt) {
logger.debug(s"Searching for nested archives:")
val jarFiles = extractByPredicate(archive, jarsDir, Extractor.acceptNestedArchive, overwrite = false, flatten = true, fallbackFilename) // overwrite=false, as we want to extract any given jar only once per staging process
// finally extract the jar files themselves (without recursively extracting jars contained inside)
for (jarFile <- jarFiles if Extractor.acceptNestedArchive(jarFile)) {
Expand Down

0 comments on commit 4d9e28d

Please sign in to comment.