Skip to content

Commit 9d5b6c3

Browse files
committed
fixed bug in file export step
1 parent 68c2bbf commit 9d5b6c3

File tree

1 file changed

+4
-33
lines changed

1 file changed

+4
-33
lines changed

Classes/Step/FileExportStep.php

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ public function backup(): bool
1919
foreach ($copyPaths as $folderName => $path) {
2020
$tmpBackupPath = Files::concatenatePaths([$this->getBackupStepPath(), $folderName]);
2121

22-
if (is_dir($path)) {
23-
$this->copyDirectory($path, $tmpBackupPath);
24-
} else {
25-
copy($path, $tmpBackupPath);
26-
}
22+
Files::copyDirectoryRecursively($path, $tmpBackupPath);
2723
}
2824

2925
return true;
@@ -36,11 +32,9 @@ public function restore(): bool
3632
foreach ($copyPaths as $folderName => $path) {
3733
$tmpBackupPath = Files::concatenatePaths([$this->getBackupStepPath(), $folderName]);
3834

39-
if (is_dir($path)) {
40-
$this->copyDirectory($tmpBackupPath, $path);
41-
} else {
42-
copy($tmpBackupPath, $path);
43-
}
35+
Files::removeDirectoryRecursively($path);
36+
Files::createDirectoryRecursively($path);
37+
Files::copyDirectoryRecursively($tmpBackupPath, $path);
4438
}
4539

4640
return true;
@@ -60,27 +54,4 @@ public function getRestoreWarning(): ?string
6054

6155
return $restoreWarning;
6256
}
63-
64-
protected function copyDirectory(string $source, string $dest)
65-
{
66-
$dir = opendir($source);
67-
mkdir($dest);
68-
69-
while(false !== ($file = readdir($dir))) {
70-
if ($file === '.' || $file === '..') {
71-
continue;
72-
}
73-
74-
$srcFile = $source.'/'.$file;
75-
$destFile = $dest.'/'.$file;
76-
77-
if (is_dir($srcFile)) {
78-
$this->copyDirectory($srcFile, $destFile);
79-
} else {
80-
copy($srcFile, $destFile);
81-
}
82-
}
83-
84-
closedir($dir);
85-
}
8657
}

0 commit comments

Comments
 (0)