From 036d241585062a59a32d066aac995cf4755ff059 Mon Sep 17 00:00:00 2001 From: Maks Snegov Date: Tue, 22 Jun 2021 06:56:26 +0300 Subject: [PATCH] Fix setting directory mtime in hardlink_dir --- spqr/curateipsum/fs.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spqr/curateipsum/fs.py b/spqr/curateipsum/fs.py index e973a77..e9cce41 100644 --- a/spqr/curateipsum/fs.py +++ b/spqr/curateipsum/fs.py @@ -248,13 +248,16 @@ def _recursive_hardlink(src, dst) -> bool: if ent.is_dir(follow_symlinks=False): _lg.debug(f"Copying directory: {ent.path} -> {ent_dst_path}") os.mkdir(ent_dst_path) + + # process directory children + _recursive_hardlink(ent.path, ent_dst_path) + + # save directory's metainfo ent_stat = ent.stat(follow_symlinks=False) os.chown(ent_dst_path, ent_stat.st_uid, ent_stat.st_gid) os.chmod(ent_dst_path, ent_stat.st_mode) os.utime(ent_dst_path, (ent_stat.st_atime, ent_stat.st_mtime)) - # process directory children - _recursive_hardlink(ent.path, ent_dst_path) continue if ent.is_file(follow_symlinks=False) or ent.is_symlink(): _lg.debug(f"Hardlink file: {ent.path} -> {ent_dst_path}")