Skip to content

Commit 89fc45b

Browse files
committed
refactor writefile
1 parent 9b373ed commit 89fc45b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

proxmox/websocket.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ func (c *VNCWebSocketClient) Write(cmd string) error {
6565

6666
func (c *VNCWebSocketClient) WriteFile(ctx context.Context, content, path string) error {
6767
c.Exec(ctx, fmt.Sprintf("rm %s", path))
68-
if _, _, err := c.Exec(ctx, fmt.Sprintf("touch %s", path)); err != nil {
69-
return err
68+
if out, _, err := c.Exec(ctx, fmt.Sprintf("touch %s", path)); err != nil {
69+
return errors.Wrap(err, out)
7070
}
71-
chunks := chunkString(content, 3000)
71+
chunks := chunkString(content, 2000)
7272
for _, chunk := range chunks {
7373
b64chunk := base64.StdEncoding.EncodeToString([]byte(chunk))
74-
_, _, err := c.Exec(ctx, fmt.Sprintf("echo %s | base64 -d >> %s", b64chunk, path))
74+
out, _, err := c.Exec(ctx, fmt.Sprintf("echo %s | base64 -d >> %s", b64chunk, path))
7575
if err != nil {
76-
return err
76+
return errors.Wrap(err, out)
7777
}
7878
}
7979
return nil

0 commit comments

Comments
 (0)