core icon indicating copy to clipboard operation
core copied to clipboard

Stray share entries in DB after deleting parent folder

Open PVince81 opened this issue 11 years ago • 8 comments

Steps to reproduce

  1. Create a folder "test"
  2. Create/upload a file "test/file.txt"
  3. Share "test/file.txt" with link
  4. Delete "test"
  5. Check "oc_shares"

Expected result

The share entry is gone.

Actual result

The share entry still exists. Also, the link share can still be opened and shows a page with an empty file or folder!

Versions

ownCloud 6 (stable6) ownCloud 7 (stable7) ownCloud 8 (stable8) master

@schiesbn I vaguely remember that there were technical issues (maybe performance) if we want to properly delete all shares

PVince81 avatar Mar 03 '15 09:03 PVince81

Workaround would be to run this https://github.com/owncloud/core/issues/12323 after a deletion (or on a regular basis).

But the other bug is that the link share doesn't give 404 directly.

PVince81 avatar Mar 03 '15 09:03 PVince81

Another case for Foreign keys? #13143

wshadow avatar Mar 03 '15 09:03 wshadow

Yeah...

CC @DeepDiver1975

PVince81 avatar Mar 03 '15 09:03 PVince81

Setting to 8.1 to keep this in mind...

PVince81 avatar Mar 03 '15 10:03 PVince81

@jnfrmarks another test case. Can probably be verified by checking that the created link share does not exist any more after deleting the parent folder. (currently if you query it with the OCS Share API you'll see that it still exist)

PVince81 avatar Mar 03 '15 10:03 PVince81

It looks like shares set directly on the deleted item (file/folder) is deleted here: https://github.com/owncloud/core/blob/master/apps/files_sharing/lib/updater.php#L89

Maybe that code needs to be extended to also do the same for all children. That's the place where I miss something like "SELECT fileid FROM children" ...

PVince81 avatar Mar 03 '15 14:03 PVince81

I guess a 8.1 scoped solution would be to trigger a background job to delete all orphaned shares (not only the currently deleted one). The query itself can be expensive in case of many orphaned entries with SQLite since we cannot use DELETE + LEFT JOIN (like MySQL allows), so better put it in a background job.

PVince81 avatar Mar 03 '15 15:03 PVince81

Duplicate of https://github.com/owncloud/core/issues/6985

PVince81 avatar Mar 23 '15 17:03 PVince81