Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sorting to the file iterator to keep consistency in different sit…
…uations
- Loading branch information
1 parent
3b357ea
commit db7e2b9
Showing
3 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.0.11 | ||
1.0.13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/* | ||
Copyright (c) 2023, Manticore Software LTD (https://manticoresearch.com) | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License version 2 or any later | ||
version. You should have received a copy of the GPL license along with this | ||
program; if you did not, you can find it at http://www.gnu.org/ | ||
*/ | ||
|
||
namespace Manticoresearch\Backup\Lib; | ||
|
||
use Iterator; | ||
use SplFileInfo; | ||
use SplHeap; | ||
|
||
/** @phpstan-ignore-next-line */ | ||
final class FileSortingIterator extends SplHeap { | ||
/** | ||
* @param Iterator<SplFileInfo> $iterator [description] | ||
* @return void | ||
*/ | ||
public function __construct(Iterator $iterator) { | ||
foreach ($iterator as $item) { | ||
$this->insert($item); | ||
} | ||
} | ||
|
||
public function compare(mixed $b, mixed $a): int { | ||
/** @var SplFileInfo $a */ | ||
/** @var SplFileInfo $b */ | ||
return strcmp($a->getRealpath(), $b->getRealpath()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters