Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/Console/Commands/DevPullCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,13 @@ private function replaceVendorFiles(string $noturRoot, string $sourcePath): void
if (!is_dir($tmpPreserve)) {
mkdir($tmpPreserve, 0755, true);

Copilot AI Feb 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mkdir($tmpPreserve, 0755, true) is not checked for failure. If the temp directory cannot be created (permissions, full disk), the subsequent rename() error will be misleading. Consider checking the mkdir() return value (and/or re-checking is_dir after) and throwing a specific exception when creation fails.

Suggested change
mkdir($tmpPreserve, 0755, true);
if (!@mkdir($tmpPreserve, 0755, true) && !is_dir($tmpPreserve)) {
throw new \RuntimeException(
"Failed to create temporary preserve directory: {$tmpPreserve}. " .
"Check permissions, available disk space, and directory ownership."
);
}

Copilot uses AI. Check for mistakes.
}
rename($dirPath, $tmpPreserve . '/' . $dir);
$tmpDest = $tmpPreserve . '/' . $dir;
if (!rename($dirPath, $tmpDest)) {
throw new \RuntimeException(
"Failed to preserve directory: {$dirPath} to {$tmpDest}. " .
"Check permissions and ensure the directory is not locked."
Comment on lines +275 to +279

Copilot AI Feb 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using sys_get_temp_dir() as the preserve destination can cause rename() to fail with cross-device link errors (EXDEV) when the system temp directory is on a different filesystem than the project/vendor directory. To make this robust, consider creating the preserve directory on the same filesystem as $noturRoot (e.g., a hidden directory adjacent to it) or falling back to a copy+delete strategy when rename() fails with EXDEV.

Copilot uses AI. Check for mistakes.
);
}
Comment on lines +276 to +281

Copilot AI Feb 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Laravel/Illuminate commands, a failed rename() can emit an E_WARNING that the framework converts into an ErrorException, which can bypass this if (!rename(...)) branch and prevent your custom RuntimeException message from being used. Consider suppressing the warning (e.g., @rename) and then throwing based on the boolean return (optionally capturing the last error message for extra detail).

Copilot uses AI. Check for mistakes.
}
}

Expand All @@ -292,7 +298,12 @@ private function replaceVendorFiles(string $noturRoot, string $sourcePath): void
if (is_dir($destPath)) {
$this->deleteDirectory($destPath);
}
rename($tmpSource, $destPath);
if (!rename($tmpSource, $destPath)) {
throw new \RuntimeException(
"Failed to restore directory: {$tmpSource} to {$destPath}. " .
"Check permissions and ensure the directory is not locked."
);
}
Comment on lines +301 to +306

Copilot AI Feb 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above: rename() failure may raise an E_WARNING that gets converted to an exception before returning false, so this branch might never run and the error output may be less actionable than intended. Suppressing the warning and throwing based on the return value will ensure this message is consistently used.

Copilot uses AI. Check for mistakes.
}
}

Expand Down