[CORE] Fix path configuration

This commit is contained in:
Diogo Peralta Cordeiro 2021-08-19 01:45:11 +01:00 committed by Hugo Sales
parent e7b985a460
commit 2b457655ea
No known key found for this signature in database
GPG Key ID: 7D0C7EAFC9D835A0
7 changed files with 8 additions and 13 deletions

View File

@ -45,14 +45,12 @@ parameters:
avatar: avatar:
server: server:
ssl: ssl:
dir: "%kernel.project_dir%/file/avatar/"
default: "/assets/default-avatar.svg" default: "/assets/default-avatar.svg"
max_size_px: 300 max_size_px: 300
cover: cover:
server: server:
ssl: ssl:
dir: "%kernel.project_dir%/file/cover/"
max_size_px: 300 max_size_px: 300
javascript: javascript:
@ -123,7 +121,6 @@ parameters:
width: 128 width: 128
height: 128 height: 128
smart_crop: false smart_crop: false
dir: "%kernel.project_dir%/file/embed/"
theme: theme:

View File

@ -323,7 +323,7 @@ class Attachment extends Entity
public function getPath() public function getPath()
{ {
$filename = $this->getFilename(); $filename = $this->getFilename();
return is_null($filename) ? null : Common::config('attachments', 'dir') . $filename; return is_null($filename) ? null : Common::config('attachments', 'dir') . DIRECTORY_SEPARATOR . $filename;
} }
public function getUrl() public function getUrl()

View File

@ -211,7 +211,7 @@ class AttachmentThumbnail extends Entity
public function getPath() public function getPath()
{ {
return Common::config('thumbnail', 'dir') . $this->getFilename(); return Common::config('thumbnail', 'dir') . DIRECTORY_SEPARATOR . $this->getFilename();
} }
public function getUrl() public function getUrl()

View File

@ -19,12 +19,10 @@
namespace App\Util\Exception; namespace App\Util\Exception;
use function App\Core\I18n\_m;
class NoSuchFileException extends NotFoundException class NoSuchFileException extends NotFoundException
{ {
public function __construct() public function __construct(string $m = 'No such file found.')
{ {
parent::__construct(_m('No such file found')); parent::__construct($m);
} }
} }

View File

@ -25,6 +25,6 @@ class NotStoredLocallyException extends NoSuchFileException
{ {
public function __construct() public function __construct()
{ {
parent::__construct(_m('This attachment is not stored locally')); parent::__construct(_m('This attachment is not stored locally.'));
} }
} }

View File

@ -54,7 +54,7 @@ class AdminTest extends GNUsocialTestCase
public function testSiteString() public function testSiteString()
{ {
$this->test(['attachments', 'dir'], fn () => INSTALLDIR . '/foo'); $this->test(['attachments', 'dir'], fn () => Common::config('storage', 'dir') . 'foo' . DIRECTORY_SEPARATOR);
} }
public function testSiteInt() public function testSiteInt()

View File

@ -35,7 +35,7 @@ class AttachmentThumbnailTest extends GNUsocialTestCase
{ {
parent::bootKernel(); parent::bootKernel();
// Data fixture already loaded this file, but we need to get it's hash to find it // Data fixture already loaded this file, but we need to get its hash to find it
$file = new \SplFileInfo(INSTALLDIR . '/tests/sample-uploads/attachment-lifecycle-target.jpg'); $file = new \SplFileInfo(INSTALLDIR . '/tests/sample-uploads/attachment-lifecycle-target.jpg');
Event::handle('HashFile', [$file->getPathname(), &$hash]); Event::handle('HashFile', [$file->getPathname(), &$hash]);
$attachment = DB::findOneBy('attachment', ['filehash' => $hash]); $attachment = DB::findOneBy('attachment', ['filehash' => $hash]);
@ -61,7 +61,7 @@ class AttachmentThumbnailTest extends GNUsocialTestCase
$attachment->deleteStorage(); $attachment->deleteStorage();
// This was deleted earlier, an the backed storage as well, so we can't generate another thumbnail // This was deleted earlier, and the backed storage as well, so we can't generate another thumbnail
static::assertThrows(NotStoredLocallyException::class, fn () => AttachmentThumbnail::getOrCreate($attachment, width: 4, height: 4, crop: false)); static::assertThrows(NotStoredLocallyException::class, fn () => AttachmentThumbnail::getOrCreate($attachment, width: 4, height: 4, crop: false));
$attachment->kill(); $attachment->kill();