Skip to content

Commit

Permalink
Test on PHP 7.3/7.4 (#369)
Browse files Browse the repository at this point in the history
* Test on PHP 7.3
* Try/catch filesystem call
* Test even on PHP 7.4
  • Loading branch information
bytehead committed Feb 4, 2020
1 parent 1b0bc70 commit a36b9a0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -3,6 +3,8 @@ language: php
php:
- 7.1
- 7.2
- 7.3
- 7.4

env:
- SYMFONY_VERSION=^3.4
Expand Down
18 changes: 14 additions & 4 deletions Uploader/Chunk/Storage/GaufretteStorage.php
Expand Up @@ -3,6 +3,7 @@
namespace Oneup\UploaderBundle\Uploader\Chunk\Storage;

use Gaufrette\Adapter\StreamFactory;
use Gaufrette\Exception\FileNotFound;
use Gaufrette\Filesystem;
use Gaufrette\FilesystemInterface;
use Oneup\UploaderBundle\Uploader\File\FilesystemFile;
Expand Down Expand Up @@ -62,15 +63,24 @@ public function clear($maxAge, $prefix = null)
// but after the files are deleted the dirs
// would remain
foreach ($matches['dirs'] as $key) {
if ($maxAge <= $now - $this->filesystem->mtime($key)) {
$toDelete[] = $key;
try {
if ($maxAge <= $now - $this->filesystem->mtime($key)) {
$toDelete[] = $key;
}
} catch (FileNotFound $exception) {
// ignore
}
}
// The same directory is returned for every file it contains
array_unique($toDelete);

foreach ($matches['keys'] as $key) {
if ($maxAge <= $now - $this->filesystem->mtime($key)) {
$this->filesystem->delete($key);
try {
if ($maxAge <= $now - $this->filesystem->mtime($key)) {
$this->filesystem->delete($key);
}
} catch (FileNotFound $exception) {
// ignore
}
}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -33,7 +33,7 @@

"require-dev": {
"amazonwebservices/aws-sdk-for-php": "1.5.*",
"knplabs/gaufrette": "0.2.*@dev",
"knplabs/gaufrette": "^0.9",
"oneup/flysystem-bundle": "^1.2|^2.0|^3.0",
"phpunit/phpunit": "^7.5",
"sensio/framework-extra-bundle": "^5.0",
Expand Down

0 comments on commit a36b9a0

Please sign in to comment.