summaryrefslogtreecommitdiff
path: root/app/Http/RequestHandlers/EditMediaFileAction.php
diff options
context:
space:
mode:
authorGreg Roach <greg@subaqua.co.uk>2020-12-27 20:12:27 +0000
committerGreg Roach <greg@subaqua.co.uk>2021-03-11 10:22:29 +0000
commitf7cf8a155e2743f3d124eef3d30a558ab062fa4b (patch)
treea45052d9dc68b2049f4848e1043f56f6782ad3dd /app/Http/RequestHandlers/EditMediaFileAction.php
parent7989fe578b0082b5d3378ee0b461904deb3802d1 (diff)
downloadwebtrees-f7cf8a155e2743f3d124eef3d30a558ab062fa4b.tar.gz
webtrees-f7cf8a155e2743f3d124eef3d30a558ab062fa4b.tar.bz2
webtrees-f7cf8a155e2743f3d124eef3d30a558ab062fa4b.zip
Remove vendor dir, add support for PHP 8.0, drop support for PHP 7.1 and 7.2
Diffstat (limited to 'app/Http/RequestHandlers/EditMediaFileAction.php')
-rw-r--r--app/Http/RequestHandlers/EditMediaFileAction.php12
1 files changed, 5 insertions, 7 deletions
diff --git a/app/Http/RequestHandlers/EditMediaFileAction.php b/app/Http/RequestHandlers/EditMediaFileAction.php
index ada0271106..e40556d72e 100644
--- a/app/Http/RequestHandlers/EditMediaFileAction.php
+++ b/app/Http/RequestHandlers/EditMediaFileAction.php
@@ -29,6 +29,8 @@ use Fisharebest\Webtrees\Services\PendingChangesService;
use Fisharebest\Webtrees\Tree;
use League\Flysystem\FileExistsException;
use League\Flysystem\FileNotFoundException;
+use League\Flysystem\FilesystemException;
+use League\Flysystem\UnableToMoveFile;
use League\Flysystem\Util;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
@@ -138,15 +140,11 @@ class EditMediaFileAction implements RequestHandlerInterface
$new = $file;
// Update the filesystem, if we can.
- if ($old !== $new && !$media_file->isExternal()) {
+ if ($old !== $new && !$media_file->isExternal() && $filesystem->fileExists($old)) {
try {
- $new = Util::normalizePath($new);
- $filesystem->rename($old, $new);
+ $filesystem->move($old, $new);
FlashMessages::addMessage(I18N::translate('The media file %1$s has been renamed to %2$s.', Html::filename($media_file->filename()), Html::filename($file)), 'info');
- } catch (FileNotFoundException $ex) {
- // The "old" file may not exist. For example, if the file was renamed on disk,
- // and we are now renaming the GEDCOM data to match.
- } catch (FileExistsException $ex) {
+ } catch (FilesystemException | UnableToMoveFile $ex) {
// Don't overwrite existing file
FlashMessages::addMessage(I18N::translate('The media file %1$s could not be renamed to %2$s.', Html::filename($media_file->filename()), Html::filename($file)), 'info');
$file = $old;