Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No longer used resources not deleted #154

Closed
2 of 8 tasks
boschkundendienst opened this issue Jan 10, 2018 · 19 comments
Closed
2 of 8 tasks

No longer used resources not deleted #154

boschkundendienst opened this issue Jan 10, 2018 · 19 comments
Labels
enhancement Feature requests and code enhancements

Comments

@boschkundendienst
Copy link

Operating system

  • Windows
  • macOS
  • Linux
  • Android
  • iOS

Application

  • Desktop
  • Mobile
  • Terminal

If it is a bug if possible please provide a screenshot showing the problem

If there is an error, please copy and paste the full error message


When adding a file to a note, eg an image it will be referenced like this:

![0805_b1e7_400.jpeg](:/f0f48abb927541f9b4cfdcad94d2ec27)

and the file is stored as

.resource\f0f48abb927541f9b4cfdcad94d2ec27

I use the folder _sync_joplin in my Dropbox as local storage for joplin data.

Now, when you delete the reference from the note, the image disappears from the note (normal behaviour) but is still present in the .resource folder. Same behaviour if you entirely delete the note itself.

Think about what happens after using the application for a very long time where you might have deleted a lot of notes, all the Files you added will still remain in the .resource folder and on operating systems, where file extensions matter you can't even double-click them to open from within the .resource folder because they do not have a file extension and.

A workarround could be to ask the user if a file is removed from a note or a note is deleted, if the file should also be deleted as a resource.

At least if a note is deleted, all files attached to it should be deleted, too.

Regards

PCFreak

@laurent22
Copy link
Owner

Yes this is a current limitation of the application - unused resources are not automatically deleted. It's on my to-do list though so it will be implemented at some point.

@marcosvega91
Copy link
Contributor

Hi @laurent22 I have create a branch for this feature in my fork, can I create a PL?

@laurent22
Copy link
Owner

laurent22 commented Jan 10, 2018

@marcosvega91, I had something quite specific in mind to get the resources cleaned up and to handle various corner cases.

For example, let's say I have a note with this content: My resource: [](:/abcd1234). Then I copy this content in a text editor and I delete the note in Joplin. Later, the content I've copied in a text editor, I copy it back in a note. If in the meantime the resource has been automatically deleted, the link [](:/abcd1234) is now invalid.

The solution I think is to keep track of the last time a resource was used in a note and if, after eg. 24h, it's still not in use, automatically delete it. I'm not keen to prompt the user every time a note is deleted either because of the UI complexity and since it's something that can be automated.

Additionally, the resources should only be auto-deleted after a long period of time to handle certain edge cases. For example, when syncing, some resources might be downloaded before the note they are linked to and, if the sync operation is spread over several days (eg. for a new device being synced with thousands of notes), the resources might be deleted before the sync operation is over. For that reason, to be safe the resources are auto-deleted only after 10 days.

What would also be useful is a screen that displays the list of resources and a way for the user to manually delete them.

@laurent22 laurent22 added the enhancement Feature requests and code enhancements label Jan 10, 2018
@jcgerhard
Copy link

I have the same issue on macOS and iOS with Nextcloud. You can create and change entries and they will be updated on the different devices. But if you delete for example a note/folder on iOS, the corresponding files in nextcloud will be deleted, too. But on macOS the changes take no effect and the concerning files/folders/entries are still there. Would be fine if this issue could be fixed soon. =:-)

@laurent22
Copy link
Owner

@jcgerhard, that sounds like a different issue. You mean if you delete a note in macOS it doesn't get deleted on the other devices via sync?

@jcgerhard
Copy link

@laurent22: you are right...it seems to be another kind of issue. I try to describe it more exactly:
I use nextcloud/webdav for synchronizing the iOS and the macOS app. This works perfect after you enabled the content-length header with the last update. If I e.g. create a new notebook and within a new note, everything‘s transfered in the right cloud folder and the other app updates the files flawlessly. This works even if I edit or create items on mobile or desktop. BUT for example: if I delete an item or a whole notebook on iOS, the apps is updated and the nextcloud folder will be updated, too. But the desktop app seems to ignore that there are deleted files on nextcloud and the old files remains. So: synchronization while creating and editing works. Deletion works only in the app you did it and the nextcloud folder...but not in the opposite app. OMG! Do you understand what I try to describe?

@laurent22
Copy link
Owner

laurent22 commented Feb 16, 2018

@jcgerhard, if you enable debug mode is there any error in the log or console? Since deletion is the last thing that the sync process does, I expect there might be an error before that.

@laurent22
Copy link
Owner

@jcgerhard, you were right, items were no longer being deleted for certain sync targets (actually all of them except OneDrive). This will be fixed in the next version and the items will be deleted as expected (no manual action will be needed).

@jcgerhard
Copy link

Sorry for the late answer...I was busy the last days.
I installed the latest version yesterday, but the issue still remains. So, an entry I delete e.g. on the desktop app will be deleted in this app and further on the webdav folder. But, following this, if I am going to take my iPhone and synch the mobile app, the entry is still there. The command for deletion never reaches the iOS app. The other way around it‘s the same. deleting something on iOS, will delete the corresponding files on nextcloud (webdav) but never reach the desktop app.

@jcgerhard
Copy link

...and if you then going to change the leftover note on iOS, you‘ll get an sync error.

@laurent22
Copy link
Owner

@jcgerhard, ah yes, that's because the iOS app hasn't been updated yet, that will be done in the coming days.

What kind of error do you get when changing the leftover note on iOS? I guess there should be a conflict?

@jcgerhard
Copy link

yes...you get a conflict if you try to change the undeleted item. I will send you the log details tomorrow.

@jcgerhard
Copy link

Good morning @laurent22! Did the iOS update and a few create-and-delete tests this morning. Everything seems to work as expected now! Items and notebooks are going to be synced and deleted properly! TOP! Thank you for fixing it!

@jcgerhard
Copy link

Please re-open issue #220 (Hiding the app) ...it´s not working properly. In the issue I described what's the problem. Thaaaanks!

@jcgerhard
Copy link

The resource-deletion-issue still exists. No longer used resource/images won't be deleted on the synchronization target (in my case Nextcloud). I did a lot of "create/edit/delete" syncing test-runs over all iDevices (iPhone/iPad/MacOS) and everything works fine. All entries are modified, synced and deleted...BUT: in every case the images won't be deleted.

@laurent22
Copy link
Owner

Yes that's why the issue is still open :-) Some background worker needs to be implemented to find and delete resources that are not linked to any note.

@laurent22
Copy link
Owner

This should now be implemented as of v1.0.78. There's a service that runs every 4 hours and mark all resources that are not linked to any notes for deletion. They are then deleted 24 hours later. These are long delays to take into account various edge cases and to avoid accidentally deleting data. Please report here if you notice that some resources are still not being deleted.

@laurent22
Copy link
Owner

Closing it for now, but feel free to report any issue here.

@corona6
Copy link

corona6 commented Mar 23, 2018

Thank you very much 🎉
I could say good bye to my script. https://gist.github.com/corona6/509264be060015d293c8d292e4637a72

@lock lock bot locked and limited conversation to collaborators Oct 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Feature requests and code enhancements
Projects
None yet
Development

No branches or pull requests

5 participants