@@ -1215,6 +1215,7 @@ def __init__(
12151215 log_json ,
12161216 iec ,
12171217 file_status_printer = None ,
1218+ files_changed = "ctime" ,
12181219 ):
12191220 self .metadata_collector = metadata_collector
12201221 self .cache = cache
@@ -1223,6 +1224,7 @@ def __init__(
12231224 self .process_file_chunks = process_file_chunks
12241225 self .show_progress = show_progress
12251226 self .print_file_status = file_status_printer or (lambda * args : None )
1227+ self .files_changed = files_changed
12261228
12271229 self .hlm = HardLinkManager (id_type = tuple , info_type = (list , type (None ))) # (dev, ino) -> chunks or None
12281230 self .stats = Statistics (output_json = log_json , iec = iec ) # threading: done by cache (including progress)
@@ -1445,21 +1447,37 @@ def process_file(self, *, path, parent_fd, name, st, cache, flags=flags_normal,
14451447 if not is_win32 : # TODO for win32
14461448 with backup_io ("fstat2" ):
14471449 st2 = os .fstat (fd )
1448- if is_special_file :
1450+ if self . files_changed == "disabled" or is_special_file :
14491451 # special files:
14501452 # - fifos change naturally, because they are fed from the other side. no problem.
14511453 # - blk/chr devices don't change ctime anyway.
14521454 pass
1453- elif st .st_ctime_ns != st2 .st_ctime_ns :
1454- # ctime was changed, this is either a metadata or a data change.
1455- changed_while_backup = True
1456- elif start_reading - TIME_DIFFERS1_NS < st2 .st_ctime_ns < end_reading + TIME_DIFFERS1_NS :
1457- # this is to treat a very special race condition, see #3536.
1458- # - file was changed right before st.ctime was determined.
1459- # - then, shortly afterwards, but already while we read the file, the
1460- # file was changed again, but st2.ctime is the same due to ctime granularity.
1461- # when comparing file ctime to local clock, widen interval by TIME_DIFFERS1_NS.
1462- changed_while_backup = True
1455+ elif self .files_changed == "ctime" :
1456+ if st .st_ctime_ns != st2 .st_ctime_ns :
1457+ # ctime was changed, this is either a metadata or a data change.
1458+ changed_while_backup = True
1459+ elif (
1460+ start_reading - TIME_DIFFERS1_NS < st2 .st_ctime_ns < end_reading + TIME_DIFFERS1_NS
1461+ ):
1462+ # this is to treat a very special race condition, see #3536.
1463+ # - file was changed right before st.ctime was determined.
1464+ # - then, shortly afterwards, but already while we read the file, the
1465+ # file was changed again, but st2.ctime is the same due to ctime granularity.
1466+ # when comparing file ctime to local clock, widen interval by TIME_DIFFERS1_NS.
1467+ changed_while_backup = True
1468+ elif self .files_changed == "mtime" :
1469+ if st .st_mtime_ns != st2 .st_mtime_ns :
1470+ # mtime was changed, this is either a data change.
1471+ changed_while_backup = True
1472+ elif (
1473+ start_reading - TIME_DIFFERS1_NS < st2 .st_mtime_ns < end_reading + TIME_DIFFERS1_NS
1474+ ):
1475+ # this is to treat a very special race condition, see #3536.
1476+ # - file was changed right before st.mtime was determined.
1477+ # - then, shortly afterwards, but already while we read the file, the
1478+ # file was changed again, but st2.mtime is the same due to mtime granularity.
1479+ # when comparing file mtime to local clock, widen interval by TIME_DIFFERS1_NS.
1480+ changed_while_backup = True
14631481 if changed_while_backup :
14641482 # regular file changed while we backed it up, might be inconsistent/corrupt!
14651483 if last_try :
0 commit comments