[Init] Initial commit - NetMesh terminal manager
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
This commit is contained in:
47
domain/sftpTransferSkip.ts
Normal file
47
domain/sftpTransferSkip.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* rsync-style "generator" skip: when size and mtime already match the target,
|
||||
* the file does not need to be transferred again.
|
||||
*
|
||||
* SFTP mtimes are typically second-precision; compare on whole seconds so a
|
||||
* local millisecond timestamp does not defeat an otherwise identical remote.
|
||||
*/
|
||||
|
||||
export type TransferMtimeUnit = "ms" | "s";
|
||||
|
||||
export interface TransferSkipIdentity {
|
||||
size: number;
|
||||
lastModified: number;
|
||||
/**
|
||||
* Preferred: adapters declare the unit. Local fs and Netcatty SFTP stats use
|
||||
* milliseconds (`Date` / `mtime * 1000`). Raw ssh2 attrs use seconds.
|
||||
* When omitted, a magnitude heuristic is used only as a legacy fallback.
|
||||
*/
|
||||
mtimeUnit?: TransferMtimeUnit;
|
||||
}
|
||||
|
||||
export function normalizeTransferMtimeSeconds(
|
||||
lastModified: number,
|
||||
mtimeUnit?: TransferMtimeUnit,
|
||||
): number {
|
||||
if (!Number.isFinite(lastModified) || lastModified <= 0) return 0;
|
||||
if (mtimeUnit === "ms") return Math.floor(lastModified / 1000);
|
||||
if (mtimeUnit === "s") return Math.floor(lastModified);
|
||||
// Legacy heuristic: magnitudes at/above 1e10 (~year 2286 as seconds) are ms.
|
||||
// Prefer passing mtimeUnit from adapters so early-1970 ms values are exact.
|
||||
return lastModified >= 1e10 ? Math.floor(lastModified / 1000) : Math.floor(lastModified);
|
||||
}
|
||||
|
||||
export function isUnchangedTransferCandidate(
|
||||
source: TransferSkipIdentity,
|
||||
target: TransferSkipIdentity,
|
||||
): boolean {
|
||||
const sourceSize = Number(source.size);
|
||||
const targetSize = Number(target.size);
|
||||
if (!Number.isFinite(sourceSize) || !Number.isFinite(targetSize)) return false;
|
||||
if (sourceSize !== targetSize) return false;
|
||||
if (sourceSize < 0 || targetSize < 0) return false;
|
||||
const sourceMtime = normalizeTransferMtimeSeconds(source.lastModified, source.mtimeUnit);
|
||||
const targetMtime = normalizeTransferMtimeSeconds(target.lastModified, target.mtimeUnit);
|
||||
if (sourceMtime <= 0 || targetMtime <= 0) return false;
|
||||
return sourceMtime === targetMtime;
|
||||
}
|
||||
Reference in New Issue
Block a user