Skip to content

Conversation

@pragneshbagary
Copy link

This PR fixes 4174,

Issue:
write_file doesn't create parent directories automatically

f, err := ts.sftp.Create(guestPath) if err != nil { return nil, nil, err }

The sftp.Create() function tries to create a file, but it doesn't create parent directories.So when written to files with no parent dierectories, sftp.Create() fails with "file does not exist".

Fix:
Ensure the parent directory exists before creating the file.
dir := filepath.Dir(guestPath) err = ts.sftp.MkdirAll(dir) if err != nil { return nil, nil, err }

filepath.Dir(guestPath) extracts the parent directory from the full path
ts.sftp.MkdirAll(dir) creates all parent directories

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test has to be updated too

@test 'write_file creates the directory if it does not yet exist' {
skip "see https://github.com/lima-vm/lima/issues/4174"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please squash the commits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

limactl-mcp: write_file doesn't not create the directory

2 participants