Skip to content

diffRemoteTrees

function diffRemoteTrees(
source: RemoteFileSystem,
sourcePath: string,
destination: RemoteFileSystem,
destinationPath: string,
options?: DiffRemoteTreesOptions): Promise<RemoteTreeDiff>;

Defined in: src/sync/diffRemoteTrees.ts:116

Compares two remote subtrees and produces an entry-level diff.

Source and destination paths are walked independently; entries are then aligned by the relative path from each tree root. Directory equality is structural - directories are equal when their relative paths match and the entry types agree.

ParameterTypeDescription
sourceRemoteFileSystemSource-side remote file system.
sourcePathstringSource-side root path being compared.
destinationRemoteFileSystemDestination-side remote file system.
destinationPathstringDestination-side root path being compared.
optionsDiffRemoteTreesOptionsOptional comparison controls.

Promise<RemoteTreeDiff>

Diff result containing entries and a summary.

import { createSyncPlan, diffRemoteTrees } from "@zero-transfer/sdk";
const diff = await diffRemoteTrees(
srcSession.fs, "/exports",
dstSession.fs, "/exports",
{ compareUniqueId: true },
);
console.log(diff.summary); // { added, removed, changed, unchanged }
const plan = createSyncPlan({
id: "exports-sync",
diff,
source: { provider: "sftp", rootPath: "/exports" },
destination: { provider: "sftp", rootPath: "/exports" },
});