From c29d386e8161635587be565a2f6f5c20cdd2c45b Mon Sep 17 00:00:00 2001 From: Vincent Donnefort Date: Tue, 22 Mar 2022 12:00:03 +0000 Subject: [PATCH] target: Allow relative path for for push/pull Currently, it is not possible to push/pull files with a relative path when the destination doesn't exist. This is due to the basename resolution. Fix this behaviour. --- devlib/target.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/devlib/target.py b/devlib/target.py index 2ad3c38..b6296d6 100644 --- a/devlib/target.py +++ b/devlib/target.py @@ -517,7 +517,7 @@ class Target(object): src_excep = HostError src_path_kind = host_paths_kind - dst_mkdir = once(self.makedirs) + _dst_mkdir = once(self.makedirs) dst_path_join = self.path.join dst_paths_kind = target_paths_kind dst_remove_file = once(functools.partial(self.remove, as_root=as_root)) @@ -525,13 +525,18 @@ class Target(object): src_excep = TargetStableError src_path_kind = target_paths_kind - dst_mkdir = once(functools.partial(os.makedirs, exist_ok=True)) + _dst_mkdir = once(functools.partial(os.makedirs, exist_ok=True)) dst_path_join = os.path.join dst_paths_kind = host_paths_kind dst_remove_file = once(os.remove) else: raise ValueError('Unknown action "{}"'.format(action)) + # Handle the case where path is None + def dst_mkdir(path): + if path: + _dst_mkdir(path) + def rewrite_dst(src, dst): new_dst = dst_path_join(dst, os.path.basename(src))