Skip to content

[10.x] Fix "Text file busy" error when call deleteDirectory - #48422

Merged
taylorotwell merged 1 commit into
laravel:10.xfrom
ycs77:fix-text-file-busy
Sep 15, 2023
Merged

[10.x] Fix "Text file busy" error when call deleteDirectory#48422
taylorotwell merged 1 commit into
laravel:10.xfrom
ycs77:fix-text-file-busy

Conversation

@ycs77

@ycs77 ycs77 commented Sep 15, 2023

Copy link
Copy Markdown
Contributor

This PR is based on #41433 and adds tests


If you call the File::deleteDirectory($dir) to delete a directory, you can see the files in the directory will be deleted, but the directory will keep it. If change the @rmdir() to rmdir() into deleteDirectory() it will be throws the ErrorException: rmdir(/home/vagrant/packages/laravel-framework/vendor/orchestra/testbench-core/laravel/storage/app/public/testdir): Text file busy error.

So this PR fixed the "Text file busy" error on call File::deleteDirectory($dir), unset the $items in deleteDirectory() to release the directory lock before calling rmdir(), does not break existing features.

Reference PR: thephpleague/flysystem#1103, thephpleague/flysystem@d03f7e1

@ycs77 ycs77 closed this Sep 15, 2023
@ycs77 ycs77 changed the title Fix "Text file busy" error when call deleteDirectory [10.x] Fix "Text file busy" error when call deleteDirectory Sep 15, 2023
@ycs77 ycs77 reopened this Sep 15, 2023
@taylorotwell
taylorotwell merged commit 6e1a5c8 into laravel:10.x Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants