flysystem: Exception thrown by Local driver attempting to create directory in quick succession
I have an application where I allow a user to pick multiple files for upload from a web form. These are then submitted individually and asynchronously using jQuery and HTML FormData.
If I have several small files submitting at once, it is possible that the server arrives at Local::ensureDirectory() almost simultaneously and the if ( ! is_dir($root)) check returns an incorrect result.
This can result in an ErrorException “mkdir(): File exists”. I’m not sure you can reproduce the error without my app, but steps would be:
- Laravel 5.2 app running on local Vagrant Homestead instance with PHP7
- Multiple async submissions to a route which should result in creation of a directory that does not yet exist
- Produces exception below:

This may well be a PHP problem and/or Vagrant not running fast enough in a local environment, but I wonder if it’s possible to mitigate, perhaps wrapping in try/catch that looks for the “File exists” message? I’ve checked the Exception thrown for other problems such as permissions and unfortunately it’s identical apart from the message - and I guess that may change in different languages.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 2
- Comments: 20 (9 by maintainers)
/s/shit/ship whoops.
I have the same issue when I use symbolic link that links outside the project (Laravel 5.2), i.e.:
The driver detects that files is not a folder via
if ( ! is_dir($root)) {and runsmkdir. The result is the same:mkdir: File existsIs it possible to include check for symbol links?