Skip to content

Commit dd92e24

Browse files
ENGCOM-5970: Fix for CLI Backup doesn't work properly when directory is a symlink … #24755
- Merge Pull Request #24755 from ivan-koliadynskyy/magento2:export-media-symlinks-13218 - Merged commits: 1. b27a576 2. 7a9f956
2 parents 6f1a6f7 + 7a9f956 commit dd92e24

File tree

1 file changed

+9
-4
lines changed
  • lib/internal/Magento/Framework/Backup/Archive

1 file changed

+9
-4
lines changed

lib/internal/Magento/Framework/Backup/Archive/Tar.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use RecursiveDirectoryIterator;
1616
use RecursiveIteratorIterator;
1717

18+
/**
19+
* Class to work with tar archives
20+
*/
1821
class Tar extends \Magento\Framework\Archive\Tar
1922
{
2023
/**
@@ -25,8 +28,7 @@ class Tar extends \Magento\Framework\Archive\Tar
2528
protected $_skipFiles = [];
2629

2730
/**
28-
* Overridden \Magento\Framework\Archive\Tar::_createTar method that does the same actions as it's parent but
29-
* filters files using \Magento\Framework\Backup\Filesystem\Iterator\Filter
31+
* Method same as it's parent but filters files using \Magento\Framework\Backup\Filesystem\Iterator\Filter
3032
*
3133
* @param bool $skipRoot
3234
* @param bool $finalize
@@ -38,9 +40,8 @@ class Tar extends \Magento\Framework\Archive\Tar
3840
protected function _createTar($skipRoot = false, $finalize = false)
3941
{
4042
$path = $this->_getCurrentFile();
41-
4243
$filesystemIterator = new RecursiveIteratorIterator(
43-
new RecursiveDirectoryIterator($path),
44+
new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::FOLLOW_SYMLINKS),
4445
RecursiveIteratorIterator::SELF_FIRST
4546
);
4647

@@ -50,6 +51,10 @@ protected function _createTar($skipRoot = false, $finalize = false)
5051
);
5152

5253
foreach ($iterator as $item) {
54+
// exclude symlinks to do not get duplicates after follow symlinks in RecursiveDirectoryIterator
55+
if ($item->isLink()) {
56+
continue;
57+
}
5358
$this->_setCurrentFile($item->getPathname());
5459
$this->_packAndWriteCurrentFile();
5560
}

0 commit comments

Comments
 (0)