generated from datalad/datalad-extension-template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #464 from mih/bf-462
`FileSystemItem.from_path()` now honors `link_target=False`
- Loading branch information
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
### 🐛 Bug Fixes | ||
|
||
- `FileSystemItem.from_path()` now honors its `link_target` parameter, and | ||
resolves a target for any symlink item conditional on this setting. | ||
Previously, a symlink target was always resolved. | ||
Fixes https://github.com/datalad/datalad-next/issues/462 via | ||
https://github.com/datalad/datalad-next/pull/464 (by @mih) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from datalad_next.tests.utils import skip_wo_symlink_capability | ||
|
||
from ..utils import FileSystemItem | ||
|
||
|
||
def test_FileSystemItem(tmp_path): | ||
testfile = tmp_path / 'file1.txt' | ||
testfile_content = 'content' | ||
testfile.write_text(testfile_content) | ||
|
||
item = FileSystemItem.from_path(testfile) | ||
assert item.size == len(testfile_content) | ||
assert item.link_target is None | ||
|
||
|
||
@skip_wo_symlink_capability | ||
def test_FileSystemItem_linktarget(tmp_path): | ||
testfile = tmp_path / 'file1.txt' | ||
testfile_content = 'short' | ||
testfile.write_text(testfile_content) | ||
testlink = tmp_path / 'link' | ||
testlink.symlink_to(testfile) | ||
|
||
item = FileSystemItem.from_path(testlink) | ||
assert testfile.samefile(item.link_target) | ||
# size of the link file does not anyhow propagate the size of the | ||
# link target | ||
assert item.size != len(testfile_content) | ||
|
||
# we can disable link resolution | ||
item = FileSystemItem.from_path(testlink, link_target=False) | ||
assert item.link_target is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters