Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Peer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { join as joinPosix } from "https://deno.land/std@0.203.0/path/posix.ts";
import { FileInfo } from "./lib/src/DirectFileManipulator.ts";
import { FilePathWithPrefix, LOG_LEVEL, LOG_LEVEL_DEBUG, LOG_LEVEL_INFO } from "./lib/src/types.ts";
import { FileInfo } from "./lib/src/API/DirectFileManipulator.ts";
import { FilePathWithPrefix, LOG_LEVEL, LOG_LEVEL_DEBUG, LOG_LEVEL_INFO } from "./lib/src/common/types.ts";
import { PeerConf, FileData } from "./types.ts";
import { Logger } from "./lib/src/logger.ts";
import { LRUCache } from "./lib/src/LRUCache.ts";
import { Logger } from "./lib/src/common/logger.ts";
import { LRUCache } from "./lib/src/memory/LRUCache.ts";
import { computeHash } from "./util.ts";

export type DispatchFun = (source: Peer, path: string, data: FileData | false) => Promise<void>;
Expand Down
10 changes: 5 additions & 5 deletions PeerCouchDB.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { DirectFileManipulator, FileInfo, MetaEntry, ReadyEntry } from "./lib/src/DirectFileManipulator.ts";
import { FilePathWithPrefix, LOG_LEVEL_NOTICE, MILSTONE_DOCID } from "./lib/src/types.ts";
import { DirectFileManipulator, FileInfo, MetaEntry, ReadyEntry } from "./lib/src/API/DirectFileManipulator.ts";
import { FilePathWithPrefix, LOG_LEVEL_NOTICE, MILSTONE_DOCID } from "./lib/src/common/types.ts";
import { PeerCouchDBConf, FileData } from "./types.ts";
import { decodeBinary } from "./lib/src/strbin.ts";
import { isPlainText } from "./lib/src/path.ts";
import { decodeBinary } from "./lib/src/string_and_binary/convert.ts";
import { isPlainText } from "./lib/src/string_and_binary/path.ts";
import { DispatchFun, Peer } from "./Peer.ts";
import { createBinaryBlob, createTextBlob, isDocContentSame } from "./lib/src/utils.ts";
import { createBinaryBlob, createTextBlob, isDocContentSame } from "./lib/src/common/utils.ts";

// export class PeerInstance()

Expand Down
11 changes: 6 additions & 5 deletions PeerStorage.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { dirname, resolve } from "https://deno.land/std@0.203.0/path/mod.ts";
import { LOG_LEVEL_INFO, LOG_LEVEL_NOTICE, LOG_LEVEL_VERBOSE } from "./lib/src/types.ts";
import { LOG_LEVEL_INFO, LOG_LEVEL_NOTICE, LOG_LEVEL_VERBOSE } from "./lib/src/common/types.ts";
import { PeerStorageConf, FileData } from "./types.ts";
import { Logger } from "./lib/src/logger.ts";
import { delay, getDocData } from "./lib/src/utils.ts";
import { isPlainText } from "./lib/src/path.ts";
import { Logger } from "./lib/src/common/logger.ts";
import { delay, getDocData } from "./lib/src/common/utils.ts";
import { isPlainText } from "./lib/src/string_and_binary/path.ts";
import { posixParse } from "https://deno.land/std@0.203.0/path/_parse.ts";
import { relative } from "https://deno.land/std@0.203.0/path/relative.ts";
import { format } from "https://deno.land/std@0.203.0/path/format.ts";
import { parse } from "https://deno.land/std@0.203.0/path/parse.ts";
import { posixFormat } from "https://deno.land/std@0.203.0/path/_format.ts";
import { scheduleOnceIfDuplicated } from "./lib/src/lock.ts";
import { scheduleOnceIfDuplicated } from "./lib/src/concurrency/lock.ts";
import { DispatchFun, Peer } from "./Peer.ts";

import chokidar from "npm:chokidar";
Expand Down Expand Up @@ -242,6 +242,7 @@ export class PeerStorage extends Peer {
awaitWriteFinish: {
stabilityThreshold: 500,
},
usePolling: this.config.usePolling,
});

this.watcher.on("change",async (path)=>{
Expand Down
5 changes: 3 additions & 2 deletions dat/config.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"$mode"
]
},
"scanOfflineChanges": true
"scanOfflineChanges": true,
"usePolling": true
}
]
}
}
144 changes: 107 additions & 37 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib
Submodule lib updated 39 files
+16 −13 src/API/DirectFileManipulator.ts
+0 −638 src/LiveSyncDBFunctions.ts
+76 −0 src/common/i18n.ts
+0 −0 src/common/logger.ts
+456 −0 src/common/rosetta.ts
+253 −31 src/common/types.ts
+221 −42 src/common/utils.ts
+35 −25 src/concurrency/lock.ts
+507 −0 src/concurrency/processor.ts
+0 −0 src/concurrency/semaphore.ts
+51 −2 src/concurrency/task.ts
+1 −1 src/dataobject/PersistentMap.ts
+27 −12 src/dataobject/reactive.ts
+4 −4 src/dataobject/store.ts
+46 −6 src/encryption/e2ee_v2.ts
+1 −1 src/index.ts
+3 −3 src/memory/LRUCache.ts
+185 −0 src/memory/memutil.ts
+3 −3 src/mock_and_interop/stores.ts
+2 −2 src/mock_and_interop/wrapper.ts
+2 −2 src/mods.ts
+796 −0 src/pouchdb/LiveSyncDBFunctions.ts
+54 −65 src/pouchdb/LiveSyncLocalDB.ts
+8 −3 src/pouchdb/pouchdb-browser.ts
+178 −60 src/pouchdb/utils_couchdb.ts
+0 −413 src/processor.ts
+117 −0 src/replication/LiveSyncAbstractReplicator.ts
+224 −189 src/replication/couchdb/LiveSyncReplicator.ts
+564 −0 src/replication/journal/JournalSyncAbstract.ts
+15 −0 src/replication/journal/JournalSyncTypes.ts
+275 −0 src/replication/journal/LiveSyncJournalReplicator.ts
+164 −0 src/replication/journal/objectstore/JournalSyncMinio.ts
+0 −629 src/strbin.ts
+306 −0 src/string_and_binary/chunks.ts
+366 −0 src/string_and_binary/convert.ts
+114 −0 src/string_and_binary/hash.ts
+4 −4 src/string_and_binary/path.ts
+22 −0 src/worker/split.worker.ts
+70 −0 src/worker/splitWorker.ts
6 changes: 3 additions & 3 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defaultLoggerEnv } from "./lib/src/logger.ts";
import { LOG_LEVEL_DEBUG } from "./lib/src/types.ts";
import { defaultLoggerEnv } from "./lib/src/common/logger.ts";
import { LOG_LEVEL_DEBUG } from "./lib/src/common/types.ts";
import { Hub } from "./Hub.ts";
import { Config } from "./types.ts";
import { parse } from "https://deno.land/std@0.202.0/flags/mod.ts";
Expand Down Expand Up @@ -27,4 +27,4 @@ try {
}
console.log("LiveSync Bridge is now started!");
const hub = new Hub(config);
hub.start();
hub.start();
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ The configuration file consists of the following structure.
// $filename and $mode have been set also in environment variables.
},
"scanOfflineChanges": true,
"usePolling": false // Optional. Use polling instead of inotify to watch file changes.
}
]
}
Expand Down
5 changes: 3 additions & 2 deletions types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DirectFileManipulatorOptions } from "./lib/src/DirectFileManipulator.ts";
import { DirectFileManipulatorOptions } from "./lib/src/API/DirectFileManipulator.ts";

export interface Config {
peers: PeerConf[];
Expand All @@ -11,6 +11,7 @@ export interface PeerStorageConf {
group?: string;
name: string;
baseDir: string;
usePolling?: boolean;
processor?: {
cmd: string,
args: string[]
Expand Down Expand Up @@ -44,4 +45,4 @@ export type FileData = {
size: number;
data: string[] | Uint8Array
deleted?: boolean;
}
}
6 changes: 3 additions & 3 deletions util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { uint8ArrayToHexString } from "./lib/src/strbin.ts";
import { createTextBlob } from "./lib/src/utils.ts";
import { uint8ArrayToHexString } from "./lib/src/string_and_binary/convert.ts";
import { createTextBlob } from "./lib/src/common/utils.ts";
export async function computeHashUInt8Array(key: Uint8Array) {
const digest = await crypto.subtle.digest('SHA-256', key);
return uint8ArrayToHexString(new Uint8Array(digest));
Expand All @@ -20,4 +20,4 @@ export function makeUniqueString() {
.map((e) => randomStrSrc[e])
.join("");
return `${Date.now()}-${temp}`;
}
}