add doc to debug

This commit is contained in:
fyears 2022-03-11 09:47:08 +08:00
parent e1d9fc1e9c
commit 6586c2a43e
5 changed files with 129 additions and 0 deletions

View File

@ -101,6 +101,10 @@ Additionally, the plugin author may occasionally visit Obsidian official forum a
- In auto sync mode, if any error occurs, the plugin would **fail silently**.
- Auto sync only works when Obsidian is being opened. It's **technically impossible** to auto sync while Obsidian is in background, because the plugin just works in the browser environment provided by Obsidian.
## How To Debug
See [here](./docs/how_to_debug/README.md) for more details.
## Bonus: Import And Export Not-Oauth2 Plugin Settings By QR Code
See [here](./docs/import_export_some_settings.md) for more details.

View File

@ -0,0 +1,11 @@
# How To Debug
Ideally, users do not need to debug anything. But if something bad happened, we have to dig into details.
## Easy: Export Sync Plans
See [here](./export_sync_plans.md).
## Advanced: Check Console Output
See [here](./check_console_output.md).

View File

@ -0,0 +1,17 @@
# Check Console Output
If you are using Obsidian on desktop, you can check the Obsidian console.
## Disable Auto Sync Firstly
You should disable auto sync to avoid any unexpected running.
## Set The Output Level To Debug
Go to the plugin settings, scroll down to the section "Debug" -> "alter console log level", and change it from "info" to "debug".
## Check The Output
Then, press the keyboard shortcut "ctrl+shift+i" if you are on Windows or Linux, or press "cmd+shift+i" if you are on macOS. You should be able to see the console of Obsidian.
Trigger the sync manually (by clicking the icon on the ribbon sidebar). Something (hopefully) helpful should show up in the console. You could understand what happened and what goes wrong more explictly by checking the output.

View File

@ -0,0 +1,95 @@
# Export Sync Plans
## What's this?
Everytime the plugin starts a sync, it gathers all required information together, generates a "sync plan" of every operations to every files and folders, and assign the corresponding actual operations.
Thus, if something goes wrong, we should check the sync plan firstly.
## How To Export The Plans?
Please read through the following instructions.
### Disable Auto Sync Firstly
You should disable auto sync to avoid any unexpected running.
### Manual Sync If Not Yet
You should at least sync once, so that at least one sync plan is generated and saved. If you have synced the vualt before, there should be some sync plans already saved.
### Export To The File
Go to the plugin settings, scroll down to the section "Debug" -> "export sync plans", and click the button "Export". \*\*It would generate a new folder `_debug_remotely_save/` in your vault, and generate a file `sync_plans_hist_exported_on_{a_timestamp},md.` inside that folder.
## How To Read The Plans
Open the genrated `sync_plans_hist_exported_on_{a_timestamp},md.`. You should see a json, or multiple jsons. Every json represents a sync plan.
A sync plan looks like this:
```json
{
"ts": 1646960867560,
"remoteType": "onedrive",
"mixedStates": {
"abc.md": {
"key": "abc.md",
"existRemote": true,
"mtimeRemote": 1646566632000,
"sizeRemote": 56797,
"remoteEncryptedKey": "abc.md",
"changeMtimeUsingMapping": true,
"existLocal": true,
"mtimeLocal": 1646566632000,
"sizeLocal": 56797,
"decision": "skipUploading",
"decisionBranch": 1
},
"New folder/": {
"key": "New folder/",
"deltimeRemote": 1646925354372,
"existLocal": false,
"existRemote": false,
"decision": "keepRemoteDelHistFolder",
"decisionBranch": 9
}
}
}
```
We usually care about the `mixedStates` property. As you may guess, every item in `mixedStates` represent a file or a folder.
We should find out the file/folder we are interested in (or we believe something goes wrong), then checkout the following properties:
```
decision
What decision is made.
decisionBranch
It's a mark of the actual logic in the sync code. Useful to debug.
existRemote
Does the file/folder exist on the remote service?
mtimeRemote
The "last modeified time" on the remote service.
deltimeRemote
The "deletion time" on the remote record.
existLocal
Does the file/folder exist locally?
mtimeLocal
The max of "last modeified time" and "creation time" locally.
deltimeLocal
The "deletion time" locally.
```
The `decision` SHOULD be determined by the modified times and deletion times, by the logic described in [the doc of sync alogorithm](../sync_algorithm_v2.md). In short, we collect four timestamps (`mtimeRemote`, `deltimeRemote`, `mtimeLocal`, `deltimeLocal`), and respect the max timestamp and its corresponding operation.
## Common Issues
Some users report that their "last modeified time"s or "creation time"s are not set correctly by the operating system. In this case, the plugin cannot do anything because it determines the sync plan by comparing the timestamps. It's suggested to check the settings of the operating system or check whether other programs are doing something to the files.

View File

@ -17,6 +17,8 @@ We list all combinations mutually exclusive and collectively exhaustive.
### Files
In short, we collect four timestamps, and respect the max timestamp and its corresponding operation.
| t1 | t2 | t3 | t4 | local file to do | remote file to do | local del history to do | remote del history to do | equal to sync v2 branch |
| -------------- | -------------- | -------------- | -------------- | ---------------- | ----------------- | ----------------------- | ------------------------ | ----------------------- |
| mtime_remote | mtime_local | deltime_remote | deltime_local | del_if_exists | del_if_exists | clean | upload_local_del_history | |