chore: Remove deprecated `Share_Helper::generateTarget` `$exclude` parameter

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/48196/head
Ferdinand Thiessen 2024-09-19 23:53:43 +07:00
parent a8f46af20f
commit e243cb8b7d
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
3 changed files with 6 additions and 15 deletions

@ -22,17 +22,16 @@ class Helper {
* check if file name already exists and generate unique target * check if file name already exists and generate unique target
* *
* @param string $path * @param string $path
* @param array $excludeList
* @param View $view * @param View $view
* @return string $path * @return string $path
*/ */
public static function generateUniqueTarget($path, $excludeList, $view) { public static function generateUniqueTarget($path, $view) {
$pathinfo = pathinfo($path); $pathinfo = pathinfo($path);
$ext = isset($pathinfo['extension']) ? '.' . $pathinfo['extension'] : ''; $ext = isset($pathinfo['extension']) ? '.' . $pathinfo['extension'] : '';
$name = $pathinfo['filename']; $name = $pathinfo['filename'];
$dir = $pathinfo['dirname']; $dir = $pathinfo['dirname'];
$i = 2; $i = 2;
while ($view->file_exists($path) || in_array($path, $excludeList)) { while ($view->file_exists($path)) {
$path = Filesystem::normalizePath($dir . '/' . $name . ' (' . $i . ')' . $ext); $path = Filesystem::normalizePath($dir . '/' . $name . ' (' . $i . ')' . $ext);
$i++; $i++;
} }

@ -65,18 +65,12 @@ class File implements \OCP\Share_Backend_File_Dependent {
* *
* @param string $itemSource * @param string $itemSource
* @param string $shareWith * @param string $shareWith
* @param array $exclude (optional)
* @return string * @return string
*/ */
public function generateTarget($itemSource, $shareWith, $exclude = null) { public function generateTarget($itemSource, $shareWith) {
$shareFolder = \OCA\Files_Sharing\Helper::getShareFolder(); $shareFolder = \OCA\Files_Sharing\Helper::getShareFolder();
$target = \OC\Files\Filesystem::normalizePath($shareFolder . '/' . basename($itemSource)); $target = \OC\Files\Filesystem::normalizePath($shareFolder . '/' . basename($itemSource));
// for group shares we return the target right away
if ($shareWith === false) {
return $target;
}
\OC\Files\Filesystem::initMountPoints($shareWith); \OC\Files\Filesystem::initMountPoints($shareWith);
$view = new \OC\Files\View('/' . $shareWith . '/files'); $view = new \OC\Files\View('/' . $shareWith . '/files');
@ -91,9 +85,7 @@ class File implements \OCP\Share_Backend_File_Dependent {
} }
} }
$excludeList = is_array($exclude) ? $exclude : []; return \OCA\Files_Sharing\Helper::generateUniqueTarget($target, $view);
return \OCA\Files_Sharing\Helper::generateUniqueTarget($target, $excludeList, $view);
} }
public function formatItems($items, $format, $parameters = null) { public function formatItems($items, $format, $parameters = null) {

@ -30,14 +30,14 @@ interface Share_Backend {
* Get a unique name of the item for the specified user * Get a unique name of the item for the specified user
* @param string $itemSource * @param string $itemSource
* @param string|false $shareWith User the item is being shared with * @param string|false $shareWith User the item is being shared with
* @param array|null $exclude List of similar item names already existing as shared items @deprecated 7.0.0
* @return string Target name * @return string Target name
* *
* This function needs to verify that the user does not already have an item with this name. * This function needs to verify that the user does not already have an item with this name.
* If it does generate a new name e.g. name_# * If it does generate a new name e.g. name_#
* @since 5.0.0 * @since 5.0.0
* @deprecated 31.0.0
*/ */
public function generateTarget($itemSource, $shareWith, $exclude = null); public function generateTarget($itemSource, $shareWith);
/** /**
* Converts the shared item sources back into the item in the specified format * Converts the shared item sources back into the item in the specified format