Skip to content

Use mtime-based files cache default on Windows#9530

Open
hiijoshi wants to merge 1 commit intoborgbackup:masterfrom
hiijoshi:fix-windows-files-cache
Open

Use mtime-based files cache default on Windows#9530
hiijoshi wants to merge 1 commit intoborgbackup:masterfrom
hiijoshi:fix-windows-files-cache

Conversation

@hiijoshi
Copy link

@hiijoshi hiijoshi commented Mar 22, 2026

Summary

Fix default files-cache mode on Windows.

On Windows, ctime represents file creation time rather than inode change time. Using ctime in the default files-cache mode can therefore fail to detect modified files correctly.

Changes

  • Use an mtime-based files cache mode on Windows
  • Keep existing ctime,size,inode default behavior unchanged on POSIX systems

Reasoning

This aligns with the issue discussion and ensures more reliable change detection on Windows systems.

Testing

  • Verified code compiles and integrates with existing logic
  • No changes to non-Windows behavior

Additional Improvement

Also added a warning when using ctime-based files cache mode on Windows, since ctime represents file creation time and may not detect file changes correctly.

Fixes #7193

Comment on lines +229 to +233
if is_win32 and "ctime" in str(args.files_cache_mode):
logger.warning(
"Using ctime on Windows may not detect file changes correctly. "
"Consider using mtime-based cache mode."
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do it like that, it will emit a warning, but then it will continue and use ctime, although we know that this won't work.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that makes sense. A warning alone would still continue with an unreliable ctime-based mode on Windows. I’ve removed that part and kept this PR focused on switching the default files-cache mode on Windows to an mtime-based mode, while leaving non-Windows behavior unchanged.

@hiijoshi hiijoshi force-pushed the fix-windows-files-cache branch from 1848149 to b6e5033 Compare March 23, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

borg2: --files-cache=ctime,inode,size (windows)

2 participants