Unable to unshare a file/folder after an ownership transfer

Nextcloud version (eg, 20.0.5): 21.0.3
Operating system and version (eg, Ubuntu 20.04): Debian GNU/Linux 10.11
Apache or nginx version (eg, Apache 2.4.25): Apache HTTP 2.4.38-3+deb10u7
PHP version (eg, 7.4): 7.3.31-1~deb10u1

The issue you are facing:

A user gave me the ownership of multiple files and folders that were shared to users, including myself (admin group).
Now I want to unshare those files and folders since they are inside a folder that already have the expected share configuration.

The unshare action went well for all users and groups, except the admin group. When I try to remove it, I get the following error:

“Error deleting the share: bad share ID, the share does not exist”

Is this the first time you’ve seen this error? (Y/N): Yes

Steps to replicate it:

  1. Having user A in group A and user B in group B
  2. As user A, create a folder and share it to group B
  3. Transfer the folder ownership to user B
  4. As user B, try to unshare the folder from group B

Note: I am not sure it replicate the error, but this is how I got it.

No useful information in the text logs.

Watching the network logs, I get the following when getting the shares:

Getting the folder with the shares

Method: GET
Filename: /ocs/v2.php/apps/files_sharing/api/v1/shares
Query:
    format=json
    path=<path_to_file>
    reshares=true
---
{
    "ocs": {
        "meta": {
            "status": "ok",
            "statuscode": 200,
            "message": "OK"
        },
        "data": [{
            "id": "1019",
            "share_type": 1,
            "uid_owner": "ncadmin",
            (...)
        }]
    }
}

And when you try to unshare that ID

Method: DELETE
Filename: /ocs/v2.php/apps/files_sharing/api/v1/shares/1019
---
{
    "ocs": {
        "meta": {
            "status": "failure",
            "statuscode": 404,
            "message": "Mauvais ID de partage, le partage n'existe pas"
        },
        "data": []
    }
}

As I understand it, I have a conflict between the DB and the files where one thinks a share still exists, but the other thinks it does not (maybe because of the ownership transfer).

The simpler solution for me would be to just unshare the files and folders for all users, no matter if the shares are valid or not. Is there a corresponding occ command?

1 Like

Hi !
We got the same problem with Nextcloud 23.
It’s impossible to create, update or delete a share link. We have this bug from several Nextcloud version now.

We hope this issue could be investigate.