Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable25] fix: catch ManuallyLockedException and use app context #38044

Merged
merged 1 commit into from
May 4, 2023

Conversation

backportbot-nextcloud[bot]
Copy link

@backportbot-nextcloud backportbot-nextcloud bot commented May 3, 2023

  • ⚠️ This backport had conflicts that were resolved with the 'ours' merge strategy and is likely incomplete

backport of #37787

$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>, 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>, 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, 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, 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, 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, possibly different type bool|resource provided
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 <max@nextcloud.com>
@max-nextcloud max-nextcloud marked this pull request as ready for review May 4, 2023 07:42
@max-nextcloud
Copy link
Contributor

/backport to stable24

@max-nextcloud max-nextcloud added the 3. to review Waiting for reviews label May 4, 2023
@juliushaertl juliushaertl merged commit f47dcbc into stable25 May 4, 2023
@juliushaertl juliushaertl deleted the backport/37787/stable25 branch May 4, 2023 09:00
@backportbot-nextcloud
Copy link
Author

The backport to stable24 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable24
git pull origin/stable24

# Create the new backport branch
git checkout -b fix/foo-stable24

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123

# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable24

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

@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
3. to review Waiting for reviews bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants