Skip to content

Commit 7e6c9bc

Browse files
authored
feat: add ability to synchronize file metadata (#27)
* feat: add ability to synchronize permissions * fix: sync flags and times too
1 parent 0da571e commit 7e6c9bc

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

conda_forge_feedstock_ops/os_utils.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,13 @@ def _all_fnames(root_dir):
7373
return fnames
7474

7575

76-
def sync_dirs(source_dir, dest_dir, ignore_dot_git=True, update_git=True):
76+
def sync_dirs(
77+
source_dir,
78+
dest_dir,
79+
ignore_dot_git=True,
80+
update_git=True,
81+
sync_stat_metadata=False,
82+
):
7783
"""Sync the contents of source_dir to dest_dir.
7884
7985
By default, this function ignores `.git` directories and will update the git index
@@ -89,6 +95,9 @@ def sync_dirs(source_dir, dest_dir, ignore_dot_git=True, update_git=True):
8995
Ignore .git directories, by default True
9096
update_git : bool, optional
9197
Update the git index via `git add` and `git rm`, by default True
98+
sync_stat_metadata : bool, optional
99+
If True, synchronize the file/directory permissions, access/modification
100+
times, and flags in addition to the contents. Default is False.
92101
"""
93102
os.makedirs(dest_dir, exist_ok=True)
94103

@@ -137,6 +146,9 @@ def sync_dirs(source_dir, dest_dir, ignore_dot_git=True, update_git=True):
137146
cwd=dest_dir,
138147
)
139148

149+
if sync_stat_metadata:
150+
shutil.copystat(src_fname, dest_fname)
151+
140152

141153
def _chmod_plus_rw(file_or_dir, skip_on_error=False):
142154
try:

0 commit comments

Comments
 (0)