Alt-er / obsidian-sync-share

Sync and share (publish) your notes in your own private service.
https://share.alter.run/share/alter/0798331c-7d63-4fa7-b312-a600ad62aea7
MIT License
92 stars 1 forks source link

Problems with syncing #18

Closed martin-arg closed 10 months ago

martin-arg commented 10 months ago

Since the last server upgrade (maybe plugin too) I've been having serious problems syncing the vault. Firstly, I keep getting the message "Other clients are in process of synchronization" when I'm sure there aren't any. Secondly, since last Friday, I have lost some files from a folder, and I have copied them back from a backup, and when the plugin syncs they are deleted again. I have already restarted the server. I'm not really sure if there's anything else I can try.

Alt-er commented 10 months ago

I'm very sorry. Have you turned on the synchronization profile function? Generally, synchronization conflicts occur because there was a problem with the last synchronization. Did you see any errors during synchronization?

martin-arg commented 10 months ago

I already disable profile synchronization and I don't see anything strange. What can I do to help?

Alt-er commented 10 months ago

I would like to ask if the synchronization configuration file was enabled when the error occurred before. I need to determine whether the problem is caused by the synchronization configuration file.

martin-arg commented 10 months ago

No It was't. I disable the sync of the config file.

martin-arg commented 10 months ago

Also, even though I only have this plug-in active in one client, I'm still getting the message "Other clients are synchronising".

Alt-er commented 10 months ago

Is your server up to date? (1.2.0) You can open http://your server Scroll to the bottom and the version number will be displayed.

Alt-er commented 10 months ago

If you are sure it is the latest version, can you do a test for me?

  1. Delete the user_store/{user}/sync_lock file on the server, if it exists
  2. Resynchronize to see if errors occur
martin-arg commented 10 months ago

Is your server up to date? (1.2.0) You can open http://your server Scroll to the bottom and the version number will be displayed.

yes

martin-arg commented 10 months ago

If you are sure it is the latest version, can you do a test for me?

1. Delete the `user_store/{user}/sync_lock` file on the server, if it exists

2. Resynchronize to see if errors occur

It exists, I delete it and try to sync again. I enable the notification in Obsidian and I never get the sync complete notification. Also, the file is still there.

Alt-er commented 10 months ago

~~Do you mean that after deleting the lock file, the file was regenerated after resynchronization was completed? Please delete the lock file, resynchronize, and turn on the synchronization notification to see if there is a prompt that the synchronization is completed.~~ If there is no prompt that synchronization is completed, an error occurred during the synchronization process.

Are you using a reverse proxy program such as nginx? They may limit the maximum file size, causing synchronization to fail.

if there is not:

You can use docker logs obsidian-sync-share-server to check the logs to see if there are any errors. If it is convenient, please send me the error logs to analyze the reasons.

martin-arg commented 10 months ago

Are you using a reverse proxy program such as nginx? They may limit the maximum file size, causing synchronization to fail.

Yes, I am, is there a way to check this?

martin-arg commented 10 months ago

obsidian-sync-share-server_logs.txt

martin-arg commented 10 months ago

For test purposes, I deleted all files over 4mb, there were few and old. But no changes.

Alt-er commented 10 months ago

Please delete the lock file, open the development window of obsidian, and then resynchronize to see if there are any errors.

image image

If it is convenient, please send a screenshot to me.

Alt-er commented 10 months ago

If there is something you don't understand, please feel free to tell me, I have time to solve the problem now

Alt-er commented 10 months ago

As far as I know, the default maximum upload file size of nginx is 1mb

You can try changing it to: client_max_body_size 1000m;

martin-arg commented 10 months ago

imagen

Alt-er commented 10 months ago

I have roughly located the place where the problem occurred, but I found no logical errors after checking the code, so I added some log printing. Can you help me test it again? Thank you very much.

  1. Replace main.js. There is a hidden .obsidian directory in your vault directory. Replace it. {vault_dir}/.obsidian/plugins/notes-sync-share/main.js
  2. After deleting the lock file, resynchronize, and open the obsidian development window to view the detailed error log

main.js.zip

Alt-er commented 10 months ago

I'm very sorry for affecting your normal use.

martin-arg commented 10 months ago

I'm very sorry for affecting your normal use.

Don't worry, you are working for free for a program that is free. These things happened.

martin-arg commented 10 months ago

imagen

Alt-er commented 10 months ago

It doesn't seem to be taking effect. I seem to have forgotten to mention that you need to restart obsidian after replacing the file for it to take effect.

Please restart obsidian and repeat the above operations.

Alt-er commented 10 months ago

I'm very sorry for affecting your normal use.

Don't worry, you are working for free for a program that is free. These things happened.

Thanks for understanding, I appreciate your help.

martin-arg commented 10 months ago

Something strange happened, I copied the file and restarted Obsidian and synced, lots of stuff appeared, I don't know why, but I deleted and synced again and took the screenshot. The strange thing is that the main file reverts back to the original as the config file sync where enabled and it's not. imagen I attach the picture so as not to look crazy.

martin-arg commented 10 months ago

imagen

imagen And so on for a few more files.

martin-arg commented 10 months ago

This last sync the sync file was erased.

martin-arg commented 10 months ago

Also the file which is complaining about is not capitalised is permissions.md

Alt-er commented 10 months ago

Only the red text is printed by my plug-in, the rest are logs from other plug-ins.

Judging from the printed information, I checked my code and there was no problem. Is there a bug in Obsidian's API?

After the replacement, the synchronization was successful because the plug-in continued to execute when it encountered an error, instead of interrupting, so it was able to work normally.

Alt-er commented 10 months ago

Also the file which is complaining about is not capitalised is permissions.md

After your reminder, I seem to understand the cause of the problem. The logic of the plug-in is to create the file when the file does not exist, but the operating system's files are not case-sensitive, resulting in a file that does not exist when checked, but cannot be created.

Alt-er commented 10 months ago

Is this the case?

There is a Permissions.md file on the server There is a file called permissions.md on your local machine

martin-arg commented 10 months ago

Yes, for this reason I'm trying to normalise the file name, to lower case and use dot insted of spaces.

Alt-er commented 10 months ago

Now that the cause of the problem has been determined, I need time to see how to solve this problem perfectly. After solving it, I will notify you of the update. Now you can use the plug-in normally, because now the same error will not interrupt synchronization. .

martin-arg commented 10 months ago

Thank you, if there is any test you would like me to do, please let me know.

Alt-er commented 10 months ago

Thank you, if there is any test you would like me to do, please let me know.

ok thanks

martin-arg commented 10 months ago

One more question, is there anyway to push changes form the client to the server? I make some changes in the client, but when I sync, the server deletes this change. I restore the files on the client and again the server deletes these changes.

Alt-er commented 10 months ago

The plug-in uses the modification time to determine the latest data of the file. The new one will overwrite the old one. The situation you are talking about should be that the time on the server is relatively new. Please check the modification times of client and server files.

martin-arg commented 10 months ago

The folders have been deleted from the server for testing purposes.

martin-arg commented 10 months ago

Sorry, let me explain, I deleted the folder from the client and they were deleted from the server. Now I restore the folder, but when I synchronise they are deleted again.

Alt-er commented 10 months ago

Yes, if it is an empty folder and has been deleted before, it will always be deleted. You have 2 ways to solve it.

  1. Put a file in the folder. If there is a file, the folder will not be deleted.
  2. Delete the user_store/{user}/server_delete_history file on the server
martin-arg commented 10 months ago

Ok, this is asking too much, but in the future can you add the option to push or pull a sync manually?

Alt-er commented 10 months ago

this is asking too much

The two methods provided above can be solved by choosing one. Generally, you only need to ensure that there are files in the folder.

but in the future can you add the option to push or pull a sync manually?

Isn’t there a manual synchronization function? Or did I misunderstand the meaning?

Alt-er commented 10 months ago

As for why deleted empty folders are always deleted, you can look at the synchronization algorithm. synchronization algorithm

martin-arg commented 10 months ago

The folder was empty, I restore the folder and all the file inside, but the sync deleted again. Yes there is a manual sync button. The push and pull option would to force to push changes even when the algorithm says otherwise, the same with the pull, I delete some files locally, and I want to restore from the server, for example.

Alt-er commented 10 months ago

Let me sort out the questions:

After deleting the folder and the files in the folder locally, restore the folder and the internal files from the backup (no modifications to the files), and then synchronize the files. The folder just restored is deleted again.

do you mean this?

in the case of

Please temporarily delete the files on the server first: user_store/{user}/server_delete_history

Let me see if there is a good way to automatically solve this problem

Alt-er commented 10 months ago

Let me sort out the questions:

After deleting the folder and the files in the folder locally, restore the folder and the internal files from the backup (no modifications to the files), and then synchronize the files. The folder just restored is deleted again.

do you mean this?

in the case of

Please temporarily delete the files on the server first: user_store/{user}/server_delete_history

Let me see if there is a good way to automatically solve this problem

This problem has been solved and will take effect in the next version

The solution is to modify the last modification time of the file to the current time when restoring the file, which can solve the problem.

The reason for this problem is that the modification time of the file does not change when the file is restored, and the server has remembered that you have deleted the file before, so it will ask the client to delete it. (Server deletion time > file last modification time)

Alt-er commented 10 months ago

New version has been released

martin-arg commented 10 months ago

After upgrading I receive this, over and over again imagen There are more, but I can capture them before they vanish. Also this imagen

Alt-er commented 10 months ago

Now if you find that the same file name (case-insensitive) appears on the server and the local file, this error will occur, and you need to change it to the same name as the server.

Because the server is case-sensitive, the easiest way is to delete these local files with the same name and then resynchronize them. The plug-in will automatically download these files.

I tried to automatically solve this problem, but I found that this cannot be solved perfectly because different operating systems are different: linux android case sensitive windows macos case-insensitive

As a result, there is no way to automatically solve it. For example, if there is a and A files on Linux, unexpected problems will occur if the files are synchronized to Windows.

Alt-er commented 10 months ago

If you have good ideas and suggestions, we can discuss them

martin-arg commented 10 months ago

Because the server is case-sensitive, the easiest way is to delete these local files with the same name and then resynchronize them. The plug-in will automatically download these files.

I try this and I didn't work. The pluginn deletes the files in the server.