MCPcopy
hub / github.com/coder/mux / buildWriteCommand

Method buildWriteCommand

src/node/runtime/SSHRuntime.ts:1129–1135  ·  view source on GitHub ↗

* Override buildWriteCommand for SSH to handle symlinks and preserve permissions.

(quotedPath: string, quotedTempPath: string)

Source from the content-addressed store, hash-verified

1127 * Override buildWriteCommand for SSH to handle symlinks and preserve permissions.
1128 */
1129 protected buildWriteCommand(quotedPath: string, quotedTempPath: string): string {
1130 // Resolve symlinks to get the actual target path, preserving the symlink itself
1131 // If target exists, save its permissions to restore after write
1132 // If path doesn't exist, use 600 as default
1133 // Then write atomically using mv (all-or-nothing for readers)
1134 return `RESOLVED=$(readlink -f ${quotedPath} 2>/dev/null || echo ${quotedPath}) && PERMS=$(stat -c '%a' "$RESOLVED" 2>/dev/null || echo 600) && mkdir -p $(dirname "$RESOLVED") && cat > ${quotedTempPath} && chmod "$PERMS" ${quotedTempPath} && mv ${quotedTempPath} "$RESOLVED"`;
1135 }
1136
1137 // ===== Runtime interface implementations =====
1138

Callers 1

writeFileFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected