@filen/sync
v0.1.95
Published
Filen Sync
Downloads
1,819
Readme
Installation
- Install using NPM
npm install @filen/sync@latest
- Initialize sync pairs
import { FilenSDK } from "@filen/sdk"
import path from "path"
import os from "os"
import { SyncWorker } from "@filen/sync"
// Initialize a SDK instance (optional)
const filen = new FilenSDK({
metadataCache: true,
connectToSocket: true,
tmpPath: path.join(os.tmpdir(), "filen-sdk")
})
await filen.login({
email: "[email protected]",
password: "supersecret123",
twoFactorCode: "123456"
})
const sync = new SyncWorker({
syncPairs: [
{
uuid: "UUIDV4", // Only used locally to identify the sync pair
localPath: pathModule.join(__dirname, "sync"), // Local absolute path
remotePath: "/sync", // Remote absolute path (UNIX style)
remoteParentUUID: "UUIDV4", // UUIDv4 of the remote parent directory
mode: "twoWay", // Sync mode
paused: false, // Start paused
excludeDotFiles: true, // Exclude dot files and paths
localTrashDisabled: false, // Disable the local trash
name: "Sync" // Only used locally to identify the sync pair
}
],
sdk: filen, // You can either directly pass a configured FilenSDK instance or instantiate a new SDK instance when passing `sdkConfig` (optional)
sdkConfig, // FilenSDK config object (omit when SDK instance is passed, needed when no SDK instance is passed)
dbPath: pathModule.join(__dirname, "db"), // Used to store sync state and other data
runOnce: false, // Run the sync once
onMessage(message) {
console.log(message.type)
}
})
// Start the sync
await sync.initialize()
License
Distributed under the AGPL-3.0 License. See LICENSE for more information.