-
Notifications
You must be signed in to change notification settings - Fork 0
Add error checking for rename() calls in DevPullCommand #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4ff91e4
6dfbe8f
e05c8f9
69580c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -272,7 +272,13 @@ private function replaceVendorFiles(string $noturRoot, string $sourcePath): void | |
| if (!is_dir($tmpPreserve)) { | ||
| mkdir($tmpPreserve, 0755, true); | ||
| } | ||
| 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
|
||
| ); | ||
| } | ||
|
Comment on lines
+276
to
+281
|
||
| } | ||
| } | ||
|
|
||
|
|
@@ -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
|
||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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 subsequentrename()error will be misleading. Consider checking themkdir()return value (and/or re-checkingis_dirafter) and throwing a specific exception when creation fails.