file browser improvements and hardening.

This commit is contained in:
KingKDot
2026-07-14 09:50:09 -05:00
parent 172703c33b
commit 9178bd0e63
17 changed files with 700 additions and 105 deletions
+23 -9
View File
@@ -359,16 +359,30 @@ func HandleFileHash(ctx context.Context, env *agentRuntime.Env, cmdID string, pa
}
defer f.Close()
if _, err := io.Copy(h, f); err != nil {
return wire.WriteMsg(ctx, env.Conn, wire.FileHashResult{
Type: "file_hash_result",
CommandID: cmdID,
Path: path,
Algorithm: algorithm,
Error: err.Error(),
})
buf := make([]byte, 256*1024)
for {
if err := ctx.Err(); err != nil {
return err
}
n, readErr := f.Read(buf)
if n > 0 {
if _, err := h.Write(buf[:n]); err != nil {
return err
}
}
if readErr == io.EOF {
break
}
if readErr != nil {
return wire.WriteMsg(ctx, env.Conn, wire.FileHashResult{
Type: "file_hash_result", CommandID: cmdID, Path: path,
Algorithm: algorithm, Error: readErr.Error(),
})
}
}
if err := ctx.Err(); err != nil {
return err
}
return wire.WriteMsg(ctx, env.Conn, wire.FileHashResult{
Type: "file_hash_result",
CommandID: cmdID,