Skip to content

Commit f93ba9e

Browse files
committed
MC-41838: Simplify paths
1 parent 85d7f24 commit f93ba9e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

AdobeStockImage/Model/Storage/Save.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,28 @@ class Save
3838
* @var IsPathExcludedInterface
3939
*/
4040
private $isPathExcluded;
41+
42+
/**
43+
* @var int|null
44+
*/
4145
private $maxFileLength;
4246

4347
/**
4448
* @param Filesystem $filesystem
4549
* @param Https $driver
4650
* @param IsPathExcludedInterface $isPathExcluded
51+
* @param int|null $maxFileLength
4752
*/
4853
public function __construct(
4954
Filesystem $filesystem,
5055
Https $driver,
5156
IsPathExcludedInterface $isPathExcluded,
52-
$maxFileLength
57+
int $maxFileLength = null
5358
) {
5459
$this->filesystem = $filesystem;
5560
$this->driver = $driver;
5661
$this->isPathExcluded = $isPathExcluded;
57-
$this->maxFileLength = $maxFileLength;
62+
$this->maxFileLength = $maxFileLength ?: 255;
5863
}
5964

6065
/**
@@ -69,12 +74,8 @@ public function __construct(
6974
*/
7075
public function execute(string $imageUrl, string $destinationPath, bool $allowOverwrite = false): void
7176
{
72-
$maxFilenameLength = $this->maxFileLength;
73-
74-
if (strlen($destinationPath) > $maxFilenameLength) {
75-
throw new \InputException(
76-
__('Destination Path is too long; must be %1 characters or less', $maxFilenameLength)
77-
);
77+
if (strlen($destinationPath) > $this->maxFileLength) {
78+
throw new LocalizedException(__('Destination Path is too long; must be %1 characters or less', $this->maxFileLength));
7879
}
7980

8081
$mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);

0 commit comments

Comments
 (0)