Skip to content

Commit ceeec5a

Browse files
authored
Merge pull request #703 from effigies/fix/fs-no-copy-atime
FIX: Use copy function that does not preserve mtime when creating fsaverage directories
2 parents 35b6435 + 26873d0 commit ceeec5a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

niworkflows/interfaces/bids.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from collections import defaultdict
55
from json import dumps, loads
66
from pathlib import Path
7-
from shutil import copytree, rmtree
7+
import shutil
88
from pkg_resources import resource_filename as _pkgres
99
import re
1010

@@ -869,10 +869,15 @@ def _run_interface(self, runtime):
869869

870870
# Finesse is overrated. Either leave it alone or completely clobber it.
871871
if dest.exists() and self.inputs.overwrite_fsaverage:
872-
rmtree(dest)
872+
shutil.rmtree(dest)
873873
if not dest.exists():
874874
try:
875-
copytree(source, dest)
875+
# Use copy instead of copy2; copy calls copymode while copy2 calls
876+
# copystat, which will preserve atime/mtime.
877+
# atime should *not* be copied to avoid triggering processes that
878+
# sweep un-accessed files.
879+
# If we want to preserve mtime, that will require a new copy function.
880+
shutil.copytree(source, dest, copy_function=shutil.copy)
876881
except FileExistsError:
877882
LOGGER.warning(
878883
"%s exists; if multiple jobs are running in parallel"

0 commit comments

Comments
 (0)