Internal rsync doesn't report directory mtime updates #30

Open
opened 2026-02-05 04:03:32 +00:00 by snegov · 0 comments
Owner

Internal rsync doesn't report directory mtime updates

Problem

Internal rsync() and external rsync_ext() produce inconsistent action outputs for directory mtime updates.

Current Behavior

File time changes:

  • Internal rsync(): yields Actions.REWRITE
  • External rsync_ext(): yields Actions.REWRITE

Directory time changes:

  • Internal rsync(): Updates mtime silently, yields nothing ✗
  • External rsync_ext(): yields Actions.UPDATE_TIME

Details

Lines 403-416 in curateipsum/fs.py restore directory mtimes after sync operations (since modifying files inside directories changes their parent mtime). However, this operation doesn't yield any action:

# restore dir mtimes in dst, updated by updating files
for src_entry in scantree(src_root_abs, dir_first=True):
    if not src_entry.is_dir():
        continue
    rel_path = src_entry.path[len(src_root_abs) + 1:]
    dst_path = os.path.join(dst_root_abs, rel_path)
    src_stat = src_entry.stat(follow_symlinks=False)
    dst_stat = os.lstat(dst_path)
    if src_stat.st_mtime != dst_stat.st_mtime:
        _lg.debug("Rsync, restoring directory mtime: %s", dst_path)
        os.utime(dst_path, (src_stat.st_atime, src_stat.st_mtime),
                 follow_symlinks=False)
        # Missing: yield rel_path, Actions.UPDATE_TIME, ""

Impact

API consumers can't consistently track what changed when switching between internal/external rsync modes.

Solution

Add yield rel_path, Actions.UPDATE_TIME, "" after the os.utime() call around line 415.

Discovery

Found during test implementation for rsync_ext() function (see TestRsyncExt in test_fs.py).

# Internal rsync doesn't report directory mtime updates ## Problem Internal `rsync()` and external `rsync_ext()` produce inconsistent action outputs for directory mtime updates. ## Current Behavior **File time changes:** - Internal `rsync()`: yields `Actions.REWRITE` ✓ - External `rsync_ext()`: yields `Actions.REWRITE` ✓ **Directory time changes:** - Internal `rsync()`: Updates mtime silently, yields nothing ✗ - External `rsync_ext()`: yields `Actions.UPDATE_TIME` ✓ ## Details Lines 403-416 in `curateipsum/fs.py` restore directory mtimes after sync operations (since modifying files inside directories changes their parent mtime). However, this operation doesn't yield any action: ```python # restore dir mtimes in dst, updated by updating files for src_entry in scantree(src_root_abs, dir_first=True): if not src_entry.is_dir(): continue rel_path = src_entry.path[len(src_root_abs) + 1:] dst_path = os.path.join(dst_root_abs, rel_path) src_stat = src_entry.stat(follow_symlinks=False) dst_stat = os.lstat(dst_path) if src_stat.st_mtime != dst_stat.st_mtime: _lg.debug("Rsync, restoring directory mtime: %s", dst_path) os.utime(dst_path, (src_stat.st_atime, src_stat.st_mtime), follow_symlinks=False) # Missing: yield rel_path, Actions.UPDATE_TIME, "" ``` ## Impact API consumers can't consistently track what changed when switching between internal/external rsync modes. ## Solution Add `yield rel_path, Actions.UPDATE_TIME, ""` after the `os.utime()` call around line 415. ## Discovery Found during test implementation for `rsync_ext()` function (see TestRsyncExt in test_fs.py).
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: snegov/cura-te-ipsum#30