From f8a246ba8c3ae5b205659d479104a63c18bd9736 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 7 Sep 2021 11:55:50 +0200 Subject: [PATCH] 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 --- webknossos/webknossos/dataset/dataset.py | 7 +++---- wkcuber/Changelog.md | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/webknossos/webknossos/dataset/dataset.py b/webknossos/webknossos/dataset/dataset.py index 32614c8c2..1c9fad7f0 100644 --- a/webknossos/webknossos/dataset/dataset.py +++ b/webknossos/webknossos/dataset/dataset.py @@ -398,9 +398,8 @@ def add_symlink_layer( if isinstance(foreign_layer, Layer): foreign_layer_path = foreign_layer.path else: - foreign_layer_path = Path(foreign_layer).absolute() + foreign_layer_path = Path(foreign_layer) - foreign_layer_path = foreign_layer_path.resolve() layer_name = foreign_layer_path.name if layer_name in self.layers.keys(): raise IndexError( @@ -410,7 +409,7 @@ def add_symlink_layer( foreign_layer_symlink_path = ( Path(os.path.relpath(foreign_layer_path, self.path)) if make_relative - else foreign_layer_path + else Path(os.path.abspath(foreign_layer_path)) ) os.symlink(foreign_layer_symlink_path, join(self.path, layer_name)) 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: else: foreign_layer_path = Path(foreign_layer) - foreign_layer_path = foreign_layer_path.resolve() + foreign_layer_path = Path(os.path.abspath(foreign_layer_path)) layer_name = foreign_layer_path.name if layer_name in self.layers.keys(): raise IndexError( diff --git a/wkcuber/Changelog.md b/wkcuber/Changelog.md index 9597641eb..422670b22 100644 --- a/wkcuber/Changelog.md +++ b/wkcuber/Changelog.md @@ -16,6 +16,7 @@ For upgrade instructions, please check the respective *Breaking Changes* section ### Changed ### Fixed +- 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) ## [0.8.13](https://github.com/scalableminds/webknossos-cuber/releases/tag/v0.8.13) - 2021-09-01 [Commits](https://github.com/scalableminds/webknossos-cuber/compare/v0.8.12...v0.8.13)