owncloud / core

:cloud: ownCloud web server core (Files, DAV, etc.)
https://owncloud.com
GNU Affero General Public License v3.0
8.39k stars 2.05k forks source link

OC\Share\Share::shareItem( .. ) Break on re-sharing #12096

Closed ratikal closed 10 years ago

ratikal commented 10 years ago

I am new to owncloud I am writing an app that creates some shares between users and groups through a custom api call. When I try to share something that is already shared the function breaks.

Also when I delete a user or group that shares files or folder the oc_share table keeps the records.

i think it has to do with owncloud and not with my app.

PVince81 commented 10 years ago

Please use the issue template: https://raw.github.com/owncloud/core/master/issue_template.md

Also tell us what API functions/endpoints you are using when creating shares.

ratikal commented 10 years ago

Steps to reproduce

  1. Create a cutom app that regiters a custom api call (GUEST allowed)
  2. When someone request that api call, app run OC\Share\Share::ShareItem( .. ) to share a folder of the logged user with another user. The second time you try to do the same thing it breaks.

Expected behaviour

I am creating an api call that creates a new user, 2 user groups some folders inside the new user home folder and want to share them with the 2 user groups.

Actual behaviour

First time run as expected. If i run it again and the share I want to make is already made it breaks.

Server configuration

Operating system: Linux mint

Web server: Nginx

Database: Mysql

PHP version: 5.5.3

ownCloud version: 7.0.2 (stable)

Updated from an older ownCloud or fresh install:

List of activated apps:

The content of config/config.php:

Insert your config.php content here

Only difference from the default is default_language..

Are you using external storage, if yes which one: local/smb/sftp/...

no

Are you using encryption: yes/no

no

Client configuration

Browser: curl (term)

Operating system: Linux

ownCloud log (data/owncloud.log)

Error   PHP     Sharing 1382 failed, because this item is already shared with hug-group2-admins at /home/nick/htdocs/oc/lib/private/share/share.php#589     2014-11-11T12:16:43+00:00
Error   OCP\Share   Sharing 1382 failed, because this item is already shared with hug-group2-admins ```
PVince81 commented 10 years ago

@schiesbn can you help with this ?

PVince81 commented 10 years ago

@ratikal thanks for the details.

schiessle commented 10 years ago

When someone request that api call, app run OC\Share\Share::ShareItem( .. ) to share a folder of the logged user with another user. The second time you try to do the same thing it breaks.

This sounds correct to me. If the file is already shared with a user/group and you try to share it again with the same user/group you get a error that the file is already shared with the user/group. It doesn't make sense to share a file multiple times with the same user/group

ratikal commented 10 years ago

I think I found out what my problem is, i have to update some files in my owncloud to be sure.

I have to catch the error to prevent the script from stoping.

ratikal commented 10 years ago

My bad its ok, you may close this

schiessle commented 10 years ago

no problem, great that you could solve the problem