File tree 2 files changed +29
-4
lines changed
2 files changed +29
-4
lines changed Original file line number Diff line number Diff line change 3
3
namespace League \Glide ;
4
4
5
5
use InvalidArgumentException ;
6
+ use League \Flysystem \FileExistsException ;
6
7
use League \Flysystem \FilesystemInterface ;
7
8
use League \Glide \Api \ApiInterface ;
8
9
use League \Glide \Filesystem \FilesystemException ;
@@ -299,10 +300,15 @@ public function makeImage()
299
300
);
300
301
}
301
302
302
- $ write = $ this ->cache ->write (
303
- $ this ->getCachePath ($ request ),
304
- $ this ->api ->run ($ request , $ source )
305
- );
303
+ try {
304
+ $ write = $ this ->cache ->write (
305
+ $ this ->getCachePath ($ request ),
306
+ $ this ->api ->run ($ request , $ source )
307
+ );
308
+ } catch (FileExistsException $ exception ) {
309
+ // Cache file failed to write. Fail silently.
310
+ return $ request ;
311
+ }
306
312
307
313
if ($ write === false ) {
308
314
throw new FilesystemException (
Original file line number Diff line number Diff line change @@ -279,6 +279,25 @@ public function testMakeImageWithUnwritableCache()
279
279
$ this ->server ->makeImage ('image.jpg ' );
280
280
}
281
281
282
+ public function testMakeImageWithExistingCacheFile ()
283
+ {
284
+ $ this ->server ->setSource (Mockery::mock ('League\Flysystem\FilesystemInterface ' , function ($ mock ) {
285
+ $ mock ->shouldReceive ('has ' )->andReturn (true )->once ();
286
+ $ mock ->shouldReceive ('read ' )->andReturn ('content ' )->once ();
287
+ }));
288
+
289
+ $ this ->server ->setCache (Mockery::mock ('League\Flysystem\FilesystemInterface ' , function ($ mock ) {
290
+ $ mock ->shouldReceive ('has ' )->andReturn (false )->once ();
291
+ $ mock ->shouldReceive ('write ' )->andThrow (new \League \Flysystem \FileExistsException ('75094881e9fd2b93063d6a5cb083091c ' ));
292
+ }));
293
+
294
+ $ this ->server ->setApi (Mockery::mock ('League\Glide\Api\ApiInterface ' , function ($ mock ) {
295
+ $ mock ->shouldReceive ('run ' )->andReturn ('content ' )->once ();
296
+ }));
297
+
298
+ $ this ->assertInstanceOf ('Symfony\Component\HttpFoundation\Request ' , $ this ->server ->makeImage ('image.jpg ' ));
299
+ }
300
+
282
301
public function testMakeImageFromSource ()
283
302
{
284
303
$ this ->server ->setSource (Mockery::mock ('League\Flysystem\FilesystemInterface ' , function ($ mock ) {
You can’t perform that action at this time.
0 commit comments