Skip to content

Commit

Permalink
Update UnpackTask.php (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
liquetsoft authored Oct 17, 2024
1 parent 7d32984 commit 53f2d38
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Pipeline/Task/UnpackTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,11 @@ public function run(State $state): State
throw TaskException::create("'%s' param must be an array", StateParameter::FILES_TO_PROCEED->value);
}

$destination = $state->getParameterString(StateParameter::PATH_TO_EXTRACT_FOLDER);
if ($destination === '') {
throw new TaskException('Destination path must be a non empty string');
} else {
$destination = new \SplFileInfo($destination);
}

$files = [];
$filesUnpacked = [];
foreach ($rawFiles as $rawFile) {
if ($rawFile instanceof UnpackerFile) {
$files[] = $filesUnpacked[] = $this->unpackFile($rawFile, $destination);
$files[] = $filesUnpacked[] = $this->unpackFile($rawFile, $state);
} else {
$files[] = $rawFile;
}
Expand All @@ -56,8 +49,15 @@ public function run(State $state): State
/**
* Распаковывает файл и возвращает путь к нему.
*/
private function unpackFile(UnpackerFile $file, \SplFileInfo $destination): string
private function unpackFile(UnpackerFile $file, State $state): string
{
$destination = $state->getParameterString(StateParameter::PATH_TO_EXTRACT_FOLDER);
if ($destination === '') {
throw new TaskException('Destination path must be a non empty string');
} else {
$destination = new \SplFileInfo($destination);
}

$res = $this->unpacker->unpackFile(
$file->getArchiveFile(),
$file->getName(),
Expand Down

0 comments on commit 53f2d38

Please sign in to comment.