{"action":"created","issue":{"url":"https://api.github.com/repos/thephpleague/glide/issues/38","labels_url":"https://api.github.com/repos/thephpleague/glide/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/thephpleague/glide/issues/38/comments","events_url":"https://api.github.com/repos/thephpleague/glide/issues/38/events","html_url":"https://github.com/thephpleague/glide/issues/38","id":59100166,"number":38,"title":"Concurrent requests for an image that has not yet been cached","user":{"login":"kevin-thackorie","id":3180931,"avatar_url":"https://avatars.githubusercontent.com/u/3180931?v=3","gravatar_id":"","url":"https://api.github.com/users/kevin-thackorie","html_url":"https://github.com/kevin-thackorie","followers_url":"https://api.github.com/users/kevin-thackorie/followers","following_url":"https://api.github.com/users/kevin-thackorie/following{/other_user}","gists_url":"https://api.github.com/users/kevin-thackorie/gists{/gist_id}","starred_url":"https://api.github.com/users/kevin-thackorie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevin-thackorie/subscriptions","organizations_url":"https://api.github.com/users/kevin-thackorie/orgs","repos_url":"https://api.github.com/users/kevin-thackorie/repos","events_url":"https://api.github.com/users/kevin-thackorie/events{/privacy}","received_events_url":"https://api.github.com/users/kevin-thackorie/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/thephpleague/glide/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-26T16:42:47Z","updated_at":"2015-02-26T18:59:11Z","closed_at":null,"body":"During concurrent requests (even with concurrency as low as 2), if the image has not yet been cached, a FileExistsException gets thrown:\r\n\r\n>PHP Fatal error:  Uncaught exception 'League\\\\Flysystem\\\\FileExistsException' with message 'File already exists at path: 0fb98a01effea237c106d20fc335afb1'\r\n\r\nI discovered this race condition issue while benchmarking performance on a VM running locally using [ApacheBench v2.3:](http://httpd.apache.org/docs/2.2/programs/ab.html)\r\n\r\n>ab -n 300 -c 2 http://images.domain.tld/item/test.jpg"},"comment":{"url":"https://api.github.com/repos/thephpleague/glide/issues/comments/76243782","html_url":"https://github.com/thephpleague/glide/issues/38#issuecomment-76243782","issue_url":"https://api.github.com/repos/thephpleague/glide/issues/38","id":76243782,"user":{"login":"tmirks","id":7409283,"avatar_url":"https://avatars.githubusercontent.com/u/7409283?v=3","gravatar_id":"","url":"https://api.github.com/users/tmirks","html_url":"https://github.com/tmirks","followers_url":"https://api.github.com/users/tmirks/followers","following_url":"https://api.github.com/users/tmirks/following{/other_user}","gists_url":"https://api.github.com/users/tmirks/gists{/gist_id}","starred_url":"https://api.github.com/users/tmirks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmirks/subscriptions","organizations_url":"https://api.github.com/users/tmirks/orgs","repos_url":"https://api.github.com/users/tmirks/repos","events_url":"https://api.github.com/users/tmirks/events{/privacy}","received_events_url":"https://api.github.com/users/tmirks/received_events","type":"User","site_admin":false},"created_at":"2015-02-26T18:59:11Z","updated_at":"2015-02-26T18:59:11Z","body":"@reinink You could have the same issue writing a blank file (i.e. multiple requests trying to write the blank file at the same time). Is there any reason the second request wouldn't just do a silent overwrite (or silent fail)?\r\n\r\nThere would be a very small performance hit because you're generating it twice, but this would be pretty rare."}}