news icon indicating copy to clipboard operation
news copied to clipboard

Restoring a deleted folder fails

Open HassoSigbjoernson opened this issue 2 years ago • 4 comments

IMPORTANT

Read and tick the following checkbox after you have created the issue or place an x inside the brackets ;)

  • [x] I have read the CONTRIBUTING.md and followed the provided tips
  • [x] I accept that the issue will be closed without comment if I do not check here
  • [x] I accept that the issue will be closed without comment if I do not fill out all items in the issue template.

Explain the Problem

In the web UI it looks like restoring deleted folders works but it actually fails (see appended error message).

And I also have a related question. The "Purge interval" option in the admin settings doesn't appear to be very useful since a deleted (and not restored) folder or feed disappears from the web UI after about 5 seconds whether this purge interval is set to 60 seconds or 60 minutes. How is that supposed to work?

Steps to Reproduce

Explain what you did to encounter the issue

  1. create folder
  2. delete folder
  3. restore folder
  4. reload page (otherwise the folder remains visible, even after the folders api endpoint is periodically called)

System Information

  • News app version: 18.0.1
  • Nextcloud version: 23.0.4
  • Cron type: system cron
  • PHP version: 8.0.18
  • Database and version: PostgreSQL 14.2 (also tested with Sqlite 3.34.1)
  • Browser and version: Firefox 100
  • OS and version: alpine fpm Docker container
Contents of nextcloud/data/nextcloud.log
nothing
Contents of Browser Error Console Read http://ggnome.com/wiki/Using_The_Browser_Error_Console if you are unsure what to put here
Possibly unhandled rejection: {"data":{"message":"Did expect one result but found none when executing: query \"SELECT * FROM `*PREFIX*news_folders` WHERE (user_id = :user_id) AND (id = :id) AND (deleted_at = 0)\"; "},"status":404,"config":{"method":"POST","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"/apps/news/folders/9/restore","headers":{"Accept":"application/json, text/plain, */*","requesttoken":"xJqgw5H1kgJPlXfSHr4Ce0UmyUESjvieP1ZRoR74KhU=:oNLk+qaloDIh5ienLNVQLClfhAB3t8jpdz8YkHWdeE8="}},"statusText":"Not Found","xhrStatus":"complete"}

HassoSigbjoernson avatar May 05 '22 05:05 HassoSigbjoernson

deleted (and not restored) folder or feed disappears from the web UI after about 5 seconds whether this purge interval is set to 60 seconds or 60 minutes. How is that supposed to work?

It'll remain on the server for that amount of time. If you call the api to restore a feed/folder it will.

SMillerDev avatar May 05 '22 06:05 SMillerDev

That doesn't seem to be very useful if there is no way to restore a deleted feed/folder because a deleted feed/folder disappears from the web ui after 5 seconds.

If that is supposed to be handled server-side than my assumption for how this should work would be something like this:

  1. you delete a folder
  2. on the server a deleted-at timestamp is set and the folder remains in the folders list you get by calling /apps/news/folders (doesn't happen at the moment)
  3. the clients continues to display the folder with the undo option
  4. the client periodically (for example every time /apps/news/folders is called) checks if x seconds have passed since the deleted at timestamp and removes the folder after that
  5. the server deletes the folder after x+60 seconds (safety margin to prevent overlap with the refresh interval)

HassoSigbjoernson avatar May 05 '22 06:05 HassoSigbjoernson

That doesn't seem to be very useful if there is no way to restore a deleted feed/folder because a deleted feed/folder disappears from the web ui after 5 seconds.

But the whole app is mostly an API, there is nothing stopping other apps from implementing this with different time limits.

If you want to implement new behavior I'll happily review a pull request.

SMillerDev avatar May 05 '22 06:05 SMillerDev

At the moment this wouldn't even be that great from the API side because there doesn't appear to be a way for the API to tell the client that a feed/folder is still there but marked for deletion. It just disappears from the list so that the client would have to keep it's own independent list of deleted feeds/folders, which IMHO isn't ideal.

I have actually started to look into the possibility of doing this "Vue rewrite" thing and experimented with the nextcloud-vue components. The problem is that I've learned only a little bit of Vue, mostly for simple data displaying, and not a lot of JavaScript, so I'm not completely sure if I can manage that. And I certainly wouldn't touch anything PHP-related.

HassoSigbjoernson avatar May 05 '22 07:05 HassoSigbjoernson