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

Create parents when creating symlink's directory #299

Merged
merged 3 commits into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyrdp/mitm/FileMapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def finalize(self):

# Whether it's a duplicate or a new file, we need to create a link to it in the filesystem clone
if self.written:
self.filesystemPath.parents[0].mkdir(exist_ok=True)
self.filesystemPath.parents[0].mkdir(exist_ok=True, parents=True)

if self.filesystemPath.exists():
self.filesystemPath.unlink()
Expand Down
4 changes: 2 additions & 2 deletions test/test_FileMapping.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
from pathlib import Path
from unittest.mock import Mock, patch, MagicMock, mock_open
from unittest.mock import Mock, patch, MagicMock, mock_open, call

from pyrdp.mitm.FileMapping import FileMapping

Expand Down Expand Up @@ -81,7 +81,7 @@ def test_finalize_createsSymlink(self, *_):
mock_mkdir.assert_called_once()
mock_symlink_to.assert_called_once()

self.assertEqual(mock_mkdir.call_args[0][0], mapping.filesystemPath.parents[0])
self.assertEqual(mock_mkdir.mock_calls[0], call(mapping.filesystemPath.parents[0], exist_ok=True, parents=True))

# The symlink must be a relative symlink.
# The symlink is in filesystems/ so the link path will start with '..'.
Expand Down