* Override buildWriteCommand for SSH to handle symlinks and preserve permissions.
(quotedPath: string, quotedTempPath: string)
| 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 |