owncloud / ocis

:atom_symbol: ownCloud Infinite Scale Stack
https://doc.owncloud.com/ocis/next/
Apache License 2.0
1.36k stars 179 forks source link

Activities. Renaming file with file-id gives move activity instead of rename #9744

Open Salipa-Gurung opened 1 month ago

Salipa-Gurung commented 1 month ago

Describe the bug

  1. Create a file: lorem.txt
  2. Rename a file with file-id
    curl -XMOVE 'https://host.docker.internal:9200/dav/spaces/{file-id}' \
    -H 'Destination: https://host.docker.internal:9200/dav/spaces/{space-id}/lorem-renamed.txt' \
    -uadmin:admin -vk
    {
    "message": "{user} moved {resource} to {space}",
    }

WIth file path:

curl -XMOVE 'https://host.docker.internal:9200/dav/spaces/{space-id}/lorem.txt' \
-H 'Destination: https://host.docker.internal:9200/dav/spaces/{space-id}/lorem-renamed.txt' \
-uadmin:admin -vk
{
  "message": "{user} renamed {oldResource} to {resource}",
}
phil-davis commented 1 month ago

And what are the definitions/requirements for the words "move" and "rename"?

"MOVE" (an HTTP method) and "mv" (a Linux command line command) are things that "move" where a file is in the file-system hierarchy.

Sometimes the file stays in the same folder, but its name is different. In that case, end-users tend to say that the file has been "renamed".

Sometimes the file goes to another folder, and its name remains the same. I suppose that is "move".

Sometimes the file goes to another folder, and with a different name - that is a "move and rename"?

kobergj commented 1 month ago

For the ocis server there is no difference between move and rename. In all manners this is a move to the server.

For user facing notifications (activities/notifications/...) we change the naming so the user isn't confused. We use a simple logic everywhere. If the parent folder stays the same, this is a rename. Everything else is considered a move. So:

Sometimes the file goes to another folder, and with a different name - that is a "move and rename"?

The server would consider this a move, not a rename.

This is also the reason for this bug. Since we address the items by itemID, the path of these items will be empty, hence the server will consider this a rename.

The fix is probably somehow related to https://github.com/owncloud/ocis/issues/9712. Our events do not contain enough data to reliably reconstruct information from them.