-
Notifications
You must be signed in to change notification settings - Fork 826
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
Fixed Local::deleteDir #1136
Fixed Local::deleteDir #1136
Conversation
Solving the issue reported here: thephpleague#1135
Is there a way to replicate the original issue with a unit test? |
@modevelops are the directories being written to during deletion? |
The problem does not occur on most of the servers so I guess there is no reliable way for unit testing this. I don't know yet what server environment causes the problem. I know clients having a hostpoint.ch server and running into this problem. |
@modevelops are they using a NAS perhaps? |
Basically, it seems like this is a race condition and your fix will not prevent it. It might limit the window, but it'll still occur. For the next version all listings will be generators to account for large listings, effectively requiring your fix to be undone. My guess is that you need some sort of locking mechanism instead. Which is often a something missing in NAS situation, for the same reasons this bug occurs. |
This was my first thought too, but no! I logged every action in the method in a file and entries were completely skipped. When I removed the unlink for files, no files were skipped anymore. Iterating an array instead solved the problem. We used my solution for several clients reported this problem and it works fine. |
@modevelops It's still unclear to me why it works, before we can narrow that down I'm not confident to put this into the package. |
The pointer of $contents changes during the foreach loop if a file gets deleted, because $contents itself changes in this process. For me it's also totally unclear why this happens only on specific servers. Would a sample script be helpful? |
That would be very helpful. |
Btw, @modevelops what is the software this is integrated in? |
I try to get the sample script done on wednesday. It's integrated in the shop software Gambio (gambio.com). |
@modevelops would be great if you can find out more about the environment on which your software is deployed (being NAS or not, being symlinked or not, etc). |
@frankdejonge I wrote the sample script and I am waiting for the permission of our client to share the link to the script with you. Here are interesting insights: EDIT: A "not" was missing. |
I just ran this without problems: <?php
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
include __DIR__ . '/vendor/autoload.php';
$filesystem = new Filesystem(new Local(__DIR__.'/test_files/'));
for ($i = 0; $i < 25000; $i++) {
$filename = 'something_' . $i . '.txt';
$filesystem->write('dirname/' . $filename, 'this');
}
var_dump($filesystem->deleteDir('dirname')); |
I bet this will fail on our clients server. I'll try it tomorrow. My script is very similar. As I said before, it's no general problem. It runs smoothly on most machines. |
@frankdejonge I sent you an email with the sample script. |
FYI: A Network File System (NFS) is used on the server with the problem. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Solving the issue reported here: #1135