Sync: Local wipe and sync command and better info
parent
c046d4a221
commit
e4a4467547
|
@ -10,6 +10,11 @@ functions:
|
||||||
command:
|
command:
|
||||||
name: "Sync: Sync"
|
name: "Sync: Sync"
|
||||||
|
|
||||||
|
wipeAndSyncCommand:
|
||||||
|
path: sync.ts:localWipeAndSyncCommand
|
||||||
|
command:
|
||||||
|
name: "Sync: Wipe Local Space and Sync"
|
||||||
|
|
||||||
check:
|
check:
|
||||||
env: server
|
env: server
|
||||||
path: sync.ts:check
|
path: sync.ts:check
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
import { store } from "$sb/plugos-syscall/mod.ts";
|
import { store } from "$sb/plugos-syscall/mod.ts";
|
||||||
import { editor, sync, system } from "$sb/silverbullet-syscall/mod.ts";
|
import {
|
||||||
|
editor,
|
||||||
|
index,
|
||||||
|
space,
|
||||||
|
sync,
|
||||||
|
system,
|
||||||
|
} from "$sb/silverbullet-syscall/mod.ts";
|
||||||
import type { SyncEndpoint } from "$sb/silverbullet-syscall/sync.ts";
|
import type { SyncEndpoint } from "$sb/silverbullet-syscall/sync.ts";
|
||||||
|
|
||||||
export async function configureCommand() {
|
export async function configureCommand() {
|
||||||
|
@ -68,6 +74,52 @@ export async function syncCommand() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function localWipeAndSyncCommand() {
|
||||||
|
let config: SyncEndpoint | undefined = await store.get("sync.config");
|
||||||
|
if (!config) {
|
||||||
|
config = await configureCommand();
|
||||||
|
if (!config) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!(await editor.confirm(
|
||||||
|
"Are you sure you want to wipe your local space and sync with the remote?",
|
||||||
|
))
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!(await editor.confirm(
|
||||||
|
"To be clear: this means all local content will be deleted with no way to recover it. Are you sure?",
|
||||||
|
))
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Wiping local pages");
|
||||||
|
await editor.flashNotification("Now wiping all pages");
|
||||||
|
for (const page of await space.listPages()) {
|
||||||
|
console.log("Deleting page", page.name);
|
||||||
|
await space.deletePage(page.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Wiping local attachments");
|
||||||
|
await editor.flashNotification("Now wiping all attachments");
|
||||||
|
for (const attachment of await space.listAttachments()) {
|
||||||
|
console.log("Deleting attachment", attachment.name);
|
||||||
|
await space.deleteAttachment(attachment.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Wiping local sync state");
|
||||||
|
await store.set("sync.snapshot", {});
|
||||||
|
|
||||||
|
// Starting actual sync
|
||||||
|
await syncCommand();
|
||||||
|
}
|
||||||
|
|
||||||
// Run on server
|
// Run on server
|
||||||
export function check(config: SyncEndpoint) {
|
export function check(config: SyncEndpoint) {
|
||||||
return sync.check(config);
|
return sync.check(config);
|
||||||
|
|
|
@ -139,7 +139,7 @@
|
||||||
.sb-bhs {
|
.sb-bhs {
|
||||||
height: 300px;
|
height: 300px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: 1000;
|
z-index: 10;
|
||||||
|
|
||||||
.sb-panel {
|
.sb-panel {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
|
@ -28,14 +28,14 @@ Don’t believe me, check this out, here’s a list of (max 10) pages in your sp
|
||||||
|name |
|
|name |
|
||||||
|---------------|
|
|---------------|
|
||||||
|Sync |
|
|Sync |
|
||||||
|
|SilverBullet |
|
||||||
|
|Getting Started|
|
||||||
|Mobile |
|
|Mobile |
|
||||||
|PLUGS |
|
|PLUGS |
|
||||||
|🔌 Plugs |
|
|🔌 Plugs |
|
||||||
|Desktop |
|
|Desktop |
|
||||||
|Server |
|
|Server |
|
||||||
|SilverBullet |
|
|
||||||
|Download |
|
|Download |
|
||||||
|Getting Started|
|
|
||||||
|Markdown |
|
|Markdown |
|
||||||
<!-- /query -->
|
<!-- /query -->
|
||||||
|
|
||||||
|
@ -49,7 +49,9 @@ In the case of `#include` this means the body will again be replaced with the pa
|
||||||
Feel free to completely remove all content on this page and make it your own, it’s just to get you started.
|
Feel free to completely remove all content on this page and make it your own, it’s just to get you started.
|
||||||
|
|
||||||
## What next?
|
## What next?
|
||||||
Generally, you can find more information about SilverBullet on its official website. You have two ways to access it:
|
If you plan to use SilverBullet on multiple devices, specifically on a [[Mobile]] device. Have a look at [[Sync]].
|
||||||
|
|
||||||
|
Beyond that, you can find more information about SilverBullet on its official website. You have two ways to access it:
|
||||||
|
|
||||||
1. Through its [regular website link](https://silverbullet.md/)
|
1. Through its [regular website link](https://silverbullet.md/)
|
||||||
2. Directly without leaving SilverBullet, through [[Cloud Links]], just click on this: [[SilverBullet]] (note that all of these will be read-only, for obvious reasons)
|
2. Directly without leaving SilverBullet, through [[Cloud Links]], just click on this: [[SilverBullet]] (note that all of these will be read-only, for obvious reasons)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
SilverBullet now has a sync engine. Let’s still consider it _experimental_, but it’s ready for use.
|
SilverBullet now has a sync engine. It’s still early in its development, so somewhat experimental. If you decided to use it **make back-ups**.
|
||||||
|
|
||||||
The synchronization algorithm implemented is [pretty much this one described here](https://unterwaditzer.net/2016/sync-algorithm.html).
|
The synchronization algorithm implemented is [pretty much the one described here](https://unterwaditzer.net/2016/sync-algorithm.html).
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
You’ll use a single SilverBullet [[Server]] as your central synchronization space, then connect any other instances of SilverBullet (likely primarily [[Mobile]] and [[Desktop]] apps, but could also be other [[Server]] instances) to it. Each “client” instance keeps track of sync snapshots that it uses to figure out what files have changed where.
|
To use SilverBullet sync, you’ll use a single SilverBullet [[Server]] as your central synchronization space, then connect any other instances of SilverBullet (likely primarily [[Mobile]] and [[Desktop]] apps, but could also be other [[Server]] instances) to it. Each “client” instance keeps track of sync snapshots that it uses to figure out what files have changed where.
|
||||||
|
|
||||||
Let’s put this information in a graph, just because we can!
|
Let’s put this information in a graph, just because we can!
|
||||||
|
|
||||||
|
@ -22,10 +22,12 @@ Here’s how to use SilverBullet’s sync functionality:
|
||||||
2. Connect any other SilverBullet instance (likely the [[Desktop]] or [[Mobile]] app) to it via the {[Sync: Configure]} command. This will ask for:
|
2. Connect any other SilverBullet instance (likely the [[Desktop]] or [[Mobile]] app) to it via the {[Sync: Configure]} command. This will ask for:
|
||||||
* A URL to connect to (the URL of the SB server configured under (1))
|
* A URL to connect to (the URL of the SB server configured under (1))
|
||||||
* A username and password (optional) if you run the server with the `--user myuser:mypass` flag (as you should)
|
* A username and password (optional) if you run the server with the `--user myuser:mypass` flag (as you should)
|
||||||
3. {[Sync: Sync]} performs a sync. It stores a local sync snapshot (basically a list of timestamps for all files in your space) in its local SQLite database every time.
|
3. Now you have two options:
|
||||||
4. Check {[Show Logs]} for sync logs.
|
1. Perform a one-time “clean sync” _wiping all local content_ and syncing down content from the sync server. For this, use the {[Sync: Wipe Local Space and Sync]} command. This is likely what you want for e.g. an initial [[Mobile]] setup.
|
||||||
|
2. Use {[Sync: Sync]} to perform a regular sync, comparing the local and remote space and generating conflicts where appropriate.
|
||||||
|
3. Check {[Show Logs]} for sync logs.
|
||||||
|
|
||||||
Right now, sync needs to be triggered manually, so run {[Sync: Sync]} whenever you feel a sync is warranted.
|
After this initial sync, **sync needs to be triggered manually**, so run {[Sync: Sync]} whenever you feel a sync is warranted.
|
||||||
|
|
||||||
## The sync process
|
## The sync process
|
||||||
1. The sync engine compares two file listings: the local one and remote one, and figures out which files have been added, changed and removed on both ends. It uses timestamps to determine changes. Note this doesn’t make any assumptions about clocks being in sync, timezones etc.
|
1. The sync engine compares two file listings: the local one and remote one, and figures out which files have been added, changed and removed on both ends. It uses timestamps to determine changes. Note this doesn’t make any assumptions about clocks being in sync, timezones etc.
|
||||||
|
|
Loading…
Reference in New Issue