Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] DockerNode creates directories instead of files when calling create_file #646

Closed
wholderll opened this issue Feb 3, 2022 · 2 comments
Assignees
Labels

Comments

@wholderll
Copy link

Description
The issue is in DockerNode.create_file, when it creates the parent directories for the new file. On line 204 of docker.py it uses file_path.name where file_path.parent was probably intended, which is preventing the file from being copied to the container.

directory = file_path.name
if str(directory) != ".":
self.cmd(f"mkdir -m {0o755:o} -p {directory}")
if self.server is not None:
self.server.remote_put(temp_path, temp_path)
self.client.copy_file(temp_path, file_path)

Suggested Fix
Line 204:
directory = file_path.parent

Source

PurePath.name

A string representing the final path component, excluding the drive and root, if any

PurePath.parent

The logical parent of the path

Not sure why pathlib doesn't use Path.filename and Path.directory; understandably not intuitive that a class named Path has a filename for its name and not the directory path.

Environment

  • OS: [e.g. Ubuntu 18.04]
  • CORE Version [e.g. 5.2.1]
  • EMANE Version [e.g. 1.2.4]
@wholderll wholderll added the bug label Feb 3, 2022
@bharnden
Copy link
Contributor

bharnden commented Feb 4, 2022

Thanks for pointing this out, I will eventually take a look at this.

@bharnden bharnden self-assigned this Feb 4, 2022
@bharnden
Copy link
Contributor

bharnden commented Feb 5, 2022

Good catch, it was right for LxcNode's but was updated wrong when some recent adjustments were made. Appreciate it.

Fix is on develop now.

@bharnden bharnden closed this as completed Feb 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants