Skip to content

Commit f8a246b

Browse files
authored
Revert symlink resolving in add_{symlink,copy}_layer (#408)
* revert symlink resolve in dataset functions * revert black changes * update changelog * make path absolute for Layer as well * avoid code duplication * fix typing
1 parent 6832c09 commit f8a246b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

webknossos/webknossos/dataset/dataset.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,8 @@ def add_symlink_layer(
398398
if isinstance(foreign_layer, Layer):
399399
foreign_layer_path = foreign_layer.path
400400
else:
401-
foreign_layer_path = Path(foreign_layer).absolute()
401+
foreign_layer_path = Path(foreign_layer)
402402

403-
foreign_layer_path = foreign_layer_path.resolve()
404403
layer_name = foreign_layer_path.name
405404
if layer_name in self.layers.keys():
406405
raise IndexError(
@@ -410,7 +409,7 @@ def add_symlink_layer(
410409
foreign_layer_symlink_path = (
411410
Path(os.path.relpath(foreign_layer_path, self.path))
412411
if make_relative
413-
else foreign_layer_path
412+
else Path(os.path.abspath(foreign_layer_path))
414413
)
415414
os.symlink(foreign_layer_symlink_path, join(self.path, layer_name))
416415
original_layer = Dataset(foreign_layer_path.parent).get_layer(layer_name)
@@ -434,7 +433,7 @@ def add_copy_layer(self, foreign_layer: Union[str, Path, Layer]) -> Layer:
434433
else:
435434
foreign_layer_path = Path(foreign_layer)
436435

437-
foreign_layer_path = foreign_layer_path.resolve()
436+
foreign_layer_path = Path(os.path.abspath(foreign_layer_path))
438437
layer_name = foreign_layer_path.name
439438
if layer_name in self.layers.keys():
440439
raise IndexError(

wkcuber/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ For upgrade instructions, please check the respective *Breaking Changes* section
1616
### Changed
1717

1818
### Fixed
19+
- Reverted that `dataset.add_symlink_layer` and `dataset.add_copy_layer` resolved the layer path if it was a symlink. [#408](https://github.com/scalableminds/webknossos-libs/pull/408)
1920

2021
## [0.8.13](https://github.com/scalableminds/webknossos-cuber/releases/tag/v0.8.13) - 2021-09-01
2122
[Commits](https://github.com/scalableminds/webknossos-cuber/compare/v0.8.12...v0.8.13)

0 commit comments

Comments
 (0)