Replies: 2 comments 1 reply
-
Feel free to PR this to the package! |
Beta Was this translation helpful? Give feedback.
-
@freekmurze Took some more time to test different methods and suppressing the copy/unlink isn't the best option either as when it tries to add the media the other process has already stolen/deleted the file and then the error happens when it tries to optimize the non-existing file. So a few things that might work:
For now, I've changed the avatar name so it gives a different temporary item name but this is probably an anti-pattern as this should never happen. I can't really make a PR since I don't know what option you'd prefer the most. I changed out the unlink for \File::delete() since this suppresses the error and gives back a boolean but then again it gives an error when optimizing the file. So what would be the best option? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
There seems to be an issue with unlinking/copying files in a parallel process. We use Fastest to run our Behat tests, there are 16 processes running at the same time. They all create a file called avatar.png, but sometimes the temp file has already been unlinked by one of the other processes so it gives an error like this:
Warning: unlink(/tmp/c56e0ace46e8abb7bee0653bc32759c9): No such file or directory in vendor/spatie/image/src/GlideConversion.php
(Happens on line 129 and sometimes line 127. Might also be possible that it happens on line 78, but we don't use that function.)
It's just a warning and doesn't happen every time we run the tests (multiple times a day), but the test fails when given this warning sadly.
Here you can see it tries the unlink on the same file multiple times a second:
Is it possible to add a check before unlinking or copying a file?
Beta Was this translation helpful? Give feedback.
All reactions