vrtmrz / obsidian-livesync

MIT License
4.81k stars 156 forks source link

Will not delete files, ever... #151

Open Kettenotter opened 1 year ago

Kettenotter commented 1 year ago

While syncing it will never delete the local files for me. Even if they are not in the database. It would also not delete when I: move a file, rename a file and so dublicates are created after syncing.

Example: DB is synced to two devices with following files:

chrome_296

Now I delete "Delete File" from Computer 1 and run Rebuild Database. On Computer 2 I use Fetch: no files will be deleted even thought one is missing from the DataBase.

chrome_297

I was never able to delete a File from any of my devices. I tested it on: Windows PC MacBook iPad iPhone

I tested it with an older version of the plugin: same results. Wasn't able to find an older version of obsidian so didn't test that.

I used fly.io as the server following the guide on this github. The tasting test server didn't work for me, couldn't connect.

vrtmrz commented 1 year ago

Thank you for asking me! This is essential behaviour, I would like to explain this.

Self-hosted LiveSync does not delete files if there are no entries on databases. Only in the case, If there are deleted or marked deleted entries, the deletion will be reflected in the storage on each device. (Even if Delete metadata of deleted files has been enabled, deletion will be marked internally in the database)

This mark will not be created if there are no files. we have to realise the file has existed and detect it has been deleted. Therefore, we should not rebuild the database before all device becomes even.

If we have deleted the files, deletion should be reflected on each device just only by that. May I ask for more about the behaviour?

plutoghost commented 1 year ago

While syncing it will never delete the local files for me. Even if they are not in the database. It would also not delete when I: move a file, rename a file and so dublicates are created after syncing.

Example: DB is synced to two devices with following files: chrome_296 Now I delete "Delete File" from Computer 1 and run Rebuild Database. On Computer 2 I use Fetch: no files will be deleted even thought one is missing from the DataBase. chrome_297

I was never able to delete a File from any of my devices. I tested it on: Windows PC MacBook iPad iPhone

I tested it with an older version of the plugin: same results. Wasn't able to find an older version of obsidian so didn't test that.

I used fly.io as the server following the guide on this github. The tasting test server didn't work for me, couldn't connect.

I have same issue, I resolve this by turn on the two option: "Disable sensible auto merging on markdown files" and "Write documents after synchronization even if they have conflict"

vrtmrz commented 1 year ago

Really thank you for your patience and the information! Finally reproduced!

I didn’t know why it does not happens on my device but now it can be investigated.

vrtmrz commented 1 year ago

@Kettenotter Sorry for misreading your issue. I finally understood after you all mentioned it. It has been fixed! Could you please try v0.17.6?

@plutoghost Thank you for your assistance! Now, these options are no longer needed.

plutoghost commented 1 year ago

@Kettenotter Sorry for misreading your issue. I finally understood after you all mentioned it. It has been fixed! Could you please try v0.17.6?

@plutoghost Thank you for your assistance! Now, these options are no longer needed.

I tested the new 0.17.6 on my phone and pc, still have same issue, fixed by turninging on the option "Write documents after synchronization even if they have conflict".

skaag commented 1 year ago

It sounds to me like a sensible default configuration to prevent data loss...! The potential for data loss is high, if you're syncing to a new vault as a subsequent device, and you have files that only exist locally.

Kettenotter commented 1 year ago

@vrtmrz Okay after some difficulties getting it on my iPhone I can happily say that its working! Tested it with iPhone, Mac and Windows and everything is syncing and deleting files as it should.

@plutoghost Did you copy it from github and check that its 0.17.6 ? Because inside the community browser its still the old version.

Kettenotter commented 1 year ago

@skaag

It sounds to me like a sensible default configuration to prevent data loss...! The potential for data loss is high, if you're syncing to a new vault as a subsequent device, and you have files that only exist locally.

Yes and No: I was expecting that it would sync to a Vault and deleting all the local files which don't exists on the server. Which is not intended as I now know. But it also would not delete files after I had synced.

skaag commented 1 year ago

But how can the sync mechanism guarantee those files should indeed be deleted? I think it could only 100% guarantee for files that it saw as new files, or files it saw on the server?

vrtmrz commented 1 year ago

@Kettenotter I am very relieved to hear that! I am wondering why it happens, but the commits of the last release 0.17.6 had been detached. Anyway, I cherry-picked commits, and now correctly upgradable. Thank you for the troublesome testing!

vrtmrz commented 1 year ago

As we have been supplemented, it is not possible to determine whether the files detected for the first time had already been deleted or whether they were deleted and then placed again. Therefore, the database must contain traces of the deletion and the time of the deletion. (This is not visible to Fauxton when Delete metadata of deleted files is enabled, but it has been remained as a record).

inode- commented 1 year ago

Didn't know if it's directly connected to this topic, but we are having similar issue but with the "conflits".

Working on 3 different devices, when I delete a file on device A, the file is deleted on device B and device C. But after deletion the file is marked as conflict also if has been deleted on all 3 devices. When I use the "pick up conflits files" the deleted file appear on the list but cannot be opened anymore.

AarZK commented 1 year ago

Same with me. I have tried to disable the option "Do not keep metadata of deleted files." in "Hatch", it works!

P.s. My obsidian version is 1.3.7 and Self-hosted LiveSync version is 0.19.17.