Merge pull request #5705 from nextcloud/backport/5703/stable23
[stable23] fix: Avoid conflicts on deck attachments folder name
This commit is contained in:
2
.github/workflows/integration.yml
vendored
2
.github/workflows/integration.yml
vendored
@@ -72,7 +72,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
tools: phpunit
|
tools: phpunit
|
||||||
extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, mysql, pdo_mysql, pgsql, pdo_pgsql,
|
extensions: mbstring, gd, iconv, fileinfo, intl, sqlite, pdo_sqlite, mysql, pdo_mysql, pgsql, pdo_pgsql,
|
||||||
coverage: none
|
coverage: none
|
||||||
|
|
||||||
- name: Set up PHPUnit
|
- name: Set up PHPUnit
|
||||||
|
|||||||
2
.github/workflows/phpunit.yml
vendored
2
.github/workflows/phpunit.yml
vendored
@@ -62,7 +62,7 @@ jobs:
|
|||||||
path: apps/${{ env.APP_NAME }}
|
path: apps/${{ env.APP_NAME }}
|
||||||
|
|
||||||
- name: Set up php ${{ matrix.php-versions }}
|
- name: Set up php ${{ matrix.php-versions }}
|
||||||
uses: shivammathur/setup-php@2.18.0
|
uses: shivammathur/setup-php@2.15.0
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
tools: phpunit
|
tools: phpunit
|
||||||
|
|||||||
@@ -176,4 +176,12 @@ class ConfigService {
|
|||||||
|
|
||||||
return $this->config->getUserValue($userId ?? $this->getUserId(), 'deck', 'attachment_folder', '/Deck');
|
return $this->config->getUserValue($userId ?? $this->getUserId(), 'deck', 'attachment_folder', '/Deck');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setAttachmentFolder(?string $userId = null, string $path): void {
|
||||||
|
if ($userId === null && $this->getUserId() === null) {
|
||||||
|
throw new NoPermissionException('Must be logged in get the attachment folder');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->config->setUserValue($userId ?? $this->getUserId(), 'deck', 'attachment_folder', $path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ use OCA\Deck\Sharing\DeckShareProvider;
|
|||||||
use OCA\Deck\StatusException;
|
use OCA\Deck\StatusException;
|
||||||
use OCP\AppFramework\Http\StreamResponse;
|
use OCP\AppFramework\Http\StreamResponse;
|
||||||
use OCP\Constants;
|
use OCP\Constants;
|
||||||
|
use OCP\Files\Folder;
|
||||||
use OCP\Files\IMimeTypeDetector;
|
use OCP\Files\IMimeTypeDetector;
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
use OCP\Files\NotFoundException;
|
use OCP\Files\NotFoundException;
|
||||||
@@ -189,6 +190,16 @@ class FilesAppService implements IAttachmentService, ICustomAttachmentService {
|
|||||||
$folder = $userFolder->newFolder($this->configService->getAttachmentFolder());
|
$folder = $userFolder->newFolder($this->configService->getAttachmentFolder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($folder->isShared()) {
|
||||||
|
$folderName = $userFolder->getNonExistingName($this->configService->getAttachmentFolder());
|
||||||
|
$folder = $userFolder->newFolder($folderName);
|
||||||
|
$this->configService->setAttachmentFolder($this->userId, $folderName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$folder instanceof Folder || $folder->isShared()) {
|
||||||
|
throw new NotFoundException('No target folder found');
|
||||||
|
}
|
||||||
|
|
||||||
$fileName = $folder->getNonExistingName($fileName);
|
$fileName = $folder->getNonExistingName($fileName);
|
||||||
$target = $folder->newFile($fileName);
|
$target = $folder->newFile($fileName);
|
||||||
$content = fopen($file['tmp_name'], 'rb');
|
$content = fopen($file['tmp_name'], 'rb');
|
||||||
|
|||||||
Reference in New Issue
Block a user