Skip to content

Commit 64c1445

Browse files
committed
B2B-2058: ImageUploader uses Name class which works only with local FS
1 parent 3ec1610 commit 64c1445

File tree

1 file changed

+12
-13
lines changed
  • lib/internal/Magento/Framework/File

1 file changed

+12
-13
lines changed

lib/internal/Magento/Framework/File/Name.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(Filesystem $filesystem = null)
3232
}
3333

3434
/**
35-
* Get new file name if the given name is in use
35+
* Gets new file name if the given name is in use
3636
*
3737
* @param string $destinationFile
3838
* @return string
@@ -46,24 +46,23 @@ public function getNewFileName(string $destinationFile)
4646
Filesystem\DriverPool::FILE
4747
)->getDriver();
4848

49+
if ($driver->isExists($destinationFile)) {
50+
return $this->generateFileName($driver, $fileInfo);
51+
}
52+
4953
/**
5054
* Try with non-local driver.
5155
*/
52-
if (!$driver->isExists($destinationFile)) {
53-
$driver = $this->filesystem->getDirectoryWrite(
54-
DirectoryList::ROOT
55-
)->getDriver();
56-
}
56+
$driver = $this->filesystem->getDirectoryWrite(DirectoryList::ROOT)->getDriver();
57+
58+
return $driver->isExists($destinationFile)
59+
? $this->generateFileName($driver, $fileInfo)
60+
: $fileInfo['basename'];
5761

58-
if ($driver->isExists($destinationFile)) {
59-
return $this->generateFileName($driver, $fileInfo);
60-
} else {
61-
return $fileInfo['basename'];
62-
}
6362
}
6463

6564
/**
66-
* Generates new file name until file with provided name doesn't exists
65+
* Generates new file name until file with provided name doesn't exist
6766
*
6867
* @param DriverInterface $driver
6968
* @param string $fileInfo
@@ -81,7 +80,7 @@ private function generateFileName($driver, $fileInfo, $index = 1)
8180
}
8281

8382
/**
84-
* Get the path information from a given file
83+
* Gets the path information from a given file
8584
*
8685
* @param string $destinationFile
8786
* @return string|string[]

0 commit comments

Comments
 (0)