Skip to content

Conversation

@backportbot-nextcloud
Copy link

backport of #37787

The files_lock app may throw ManuallyLockedExceptions
when attempting to revert a file that is currently opened.
This would prevent the user from rolling back a opened file.

Text and Richdocuments handle changes of the file while editing.
Allow reverting files even when they are locked by these apps
and let the apps handle the conflict.

Signed-off-by: Max <[email protected]>
$storage1->unlink($internalPath1);
try {
// TODO add a proper way of overwriting a file while maintaining file ids
if ($storage1->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage') || $storage2->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage')) {

Check notice

Code scanning / Psalm

ArgumentTypeCoercion

Argument 1 of OC\Files\Storage\Storage::instanceOfStorage expects class-string<OCP\Files\Storage\IStorage>, but parent type "\\OC\\Files\\ObjectStore\\ObjectStoreStorage" provided
$storage1->unlink($internalPath1);
try {
// TODO add a proper way of overwriting a file while maintaining file ids
if ($storage1->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage') || $storage2->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage')) {

Check notice

Code scanning / Psalm

ArgumentTypeCoercion

Argument 1 of OC\Files\Storage\Storage::instanceOfStorage expects class-string<OCP\Files\Storage\IStorage>, but parent type "\\OC\\Files\\ObjectStore\\ObjectStoreStorage" provided
if ($storage1->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage') || $storage2->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage')) {
$source = $storage1->fopen($internalPath1, 'r');
$target = $storage2->fopen($internalPath2, 'w');
[, $result] = \OC_Helper::streamCopy($source, $target);

Check notice

Code scanning / Psalm

PossiblyInvalidArgument

Argument 1 of OC_Helper::streamCopy expects resource, but possibly different type bool|mixed|resource provided
if ($storage1->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage') || $storage2->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage')) {
$source = $storage1->fopen($internalPath1, 'r');
$target = $storage2->fopen($internalPath2, 'w');
[, $result] = \OC_Helper::streamCopy($source, $target);

Check notice

Code scanning / Psalm

PossiblyInvalidArgument

Argument 2 of OC_Helper::streamCopy expects resource, but possibly different type bool|resource provided
$source = $storage1->fopen($internalPath1, 'r');
$target = $storage2->fopen($internalPath2, 'w');
[, $result] = \OC_Helper::streamCopy($source, $target);
fclose($source);

Check notice

Code scanning / Psalm

PossiblyInvalidArgument

Argument 1 of fclose expects resource, but possibly different type bool|mixed|resource provided
$target = $storage2->fopen($internalPath2, 'w');
[, $result] = \OC_Helper::streamCopy($source, $target);
fclose($source);
fclose($target);

Check notice

Code scanning / Psalm

PossiblyInvalidArgument

Argument 1 of fclose expects resource, but possibly different type bool|resource provided
@max-nextcloud max-nextcloud merged commit 0ee02af into stable26 May 3, 2023
@max-nextcloud max-nextcloud deleted the backport/37787/stable26 branch May 3, 2023 14:35
@blizzz blizzz mentioned this pull request May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants