Skip to content

Commit 95bb4cb

Browse files
authored
Merge branch 'main' into rename
2 parents 1bbf838 + 6b3b841 commit 95bb4cb

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/SPC/ConsoleApplication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535
final class ConsoleApplication extends Application
3636
{
37-
public const string VERSION = '2.7.8';
37+
public const string VERSION = '2.7.9';
3838

3939
public function __construct()
4040
{

src/SPC/builder/extension/maxminddb.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,21 @@
55
namespace SPC\builder\extension;
66

77
use SPC\builder\Extension;
8+
use SPC\store\FileSystem;
89
use SPC\util\CustomExt;
910

1011
#[CustomExt('maxminddb')]
1112
class maxminddb extends Extension
1213
{
1314
public function patchBeforeBuildconf(): bool
1415
{
15-
if (!is_link(SOURCE_PATH . '/php-src/ext/maxminddb')) {
16+
if (!is_dir(SOURCE_PATH . '/php-src/ext/maxminddb')) {
1617
$original = $this->source_dir;
17-
if (PHP_OS_FAMILY === 'Windows') {
18-
f_passthru('cd ' . SOURCE_PATH . '/php-src/ext && mklink /D maxminddb ' . $original . '\ext');
19-
} else {
20-
f_passthru('cd ' . SOURCE_PATH . '/php-src/ext && ln -s ' . $original . '/ext maxminddb');
21-
}
18+
FileSystem::copyDir($original . '/ext', SOURCE_PATH . '/php-src/ext/maxminddb');
19+
$this->source_dir = SOURCE_PATH . '/php-src/ext/maxminddb';
2220
return true;
2321
}
22+
$this->source_dir = SOURCE_PATH . '/php-src/ext/maxminddb';
2423
return false;
2524
}
2625
}

src/SPC/store/FileSystem.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,11 +660,19 @@ private static function moveFileOrDir(string $source, string $dest): void
660660
$source = self::convertPath($source);
661661
$dest = self::convertPath($dest);
662662

663-
// Try rename first (fast, atomic)
664-
if (@rename($source, $dest)) {
665-
return;
663+
// Check if source and dest are on the same device to avoid cross-device rename errors
664+
$source_stat = @stat($source);
665+
$dest_parent = dirname($dest);
666+
$dest_stat = @stat($dest_parent);
667+
668+
// Only use rename if on same device
669+
if ($source_stat !== false && $dest_stat !== false && $source_stat['dev'] === $dest_stat['dev']) {
670+
if (@rename($source, $dest)) {
671+
return;
672+
}
666673
}
667674

675+
// Fall back to copy + delete for cross-device moves or if rename failed
668676
if (is_dir($source)) {
669677
self::copyDir($source, $dest);
670678
self::removeDir($source);

0 commit comments

Comments
 (0)