Skip to content

add add_metadata_plan.md - #5

Merged
messa merged 5 commits into
202601_update_metadatafrom
claude/rsync-file-matching-review-yzfZd
Jan 26, 2026
Merged

messa merged 5 commits into
202601_update_metadatafrom
claude/rsync-file-matching-review-yzfZd

Conversation

@messa

@messa messa commented Jan 26, 2026

Copy link
Copy Markdown
Owner

No description provided.

Document the main goal: after blockcopy sync, rsync should consider
files identical. Added detailed analysis of rsync's "quick check"
algorithm based on rsync source code (generator.c, util1.c):

- rsync compares size first, then mtime (seconds only by default)
- with -a flag also checks permissions and owner/group
- plan will achieve compatibility when using --truncate --times
  --perms --owner --group options together
Rsync's "quick check" only considers size and mtime when deciding
whether to transfer file content. Permissions, owner, and group are
only updated via set_file_attrs() without triggering content transfer.

This means --truncate and --times are sufficient for rsync compatibility.
The --perms/--owner/--group options are optional extras.
New test file tests/test_rsync_compat.py with three tests:
- test_rsync_sees_no_changes_after_blockcopy: main test verifying
  rsync sees no differences after blockcopy --truncate --times
- test_rsync_sees_no_changes_with_full_metadata: with --perms too
- test_rsync_without_times_would_transfer: negative test confirming
  rsync DOES see mtime difference without --times option

Tests use rsync --dry-run --itemize-changes to verify behavior.
New test verifies blockcopy preserves full nanosecond mtime precision,
compatible with rsync's strict nanosecond comparison mode (requires
rsync >= 3.1.3).
- Skip rsync compat tests locally if rsync not installed
- Fail with error on CI if rsync missing (CI must have rsync)
- Detect CI via common env vars: CI, GITHUB_ACTIONS, GITLAB_CI, JENKINS_URL
Copilot AI review requested due to automatic review settings January 26, 2026 08:00
@messa
messa changed the base branch from main to 202601_update_metadata January 26, 2026 08:01
@messa
messa merged commit 6a6e477 into 202601_update_metadata Jan 26, 2026
27 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a design/implementation plan for preserving file metadata during save (to make blockcopy outputs rsync-friendly), plus a small robustness fix in the save protocol parser.

Changes:

  • Add an explicit length check when reading the Done payload in do_save() to avoid silently parsing partial reads.
  • Add add_metadata_plan.md describing proposed metadata-preservation flags and a new Meta protocol command.
  • Add a short TODO.md for follow-up work items.

Reviewed changes

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

File Description
blockcopy.py Harden save by rejecting incomplete reads of the Done size field.
add_metadata_plan.md New planning document for rsync-compatible metadata preservation and protocol changes.
TODO.md Tracks next steps (version bump, README update).
Comments suppressed due to low confidence (2)

add_metadata_plan.md:676

  • The plan describes a new protocol command as both Meta and meta (e.g., meta (4 bytes "Meta") and the command order shows meta), while earlier examples write b'Meta' but the save-side snippet checks b'meta'. Since the protocol command bytes are case-sensitive, standardize on one exact 4-byte token throughout the document (and in the eventual implementation) to avoid an incompatible sender/receiver.
Formát:

meta (4 bytes "Meta")
atime_ns (8 bytes, signed big-endian)
mtime_ns (8 bytes, signed big-endian)
mode (4 bytes, unsigned big-endian)
uid (4 bytes, unsigned big-endian)
gid (4 bytes, unsigned big-endian)
owner_name_len (2 bytes, unsigned big-endian)
owner_name (owner_name_len bytes, UTF-8)
group_name_len (2 bytes, unsigned big-endian)
group_name (group_name_len bytes, UTF-8)


Fixní část: 4 + 8 + 8 + 4 + 4 + 4 + 2 + 2 = 36 bajtů + délka jmen

Pořadí příkazů v protokolu: `data/dlzm...` → `meta` → `Done`

add_metadata_plan.md:681

  • This section includes absolute local paths under /home/..., which are machine-specific and leak local environment details. Prefer repository-relative paths (e.g., blockcopy.py, tests/test_copy.py) or omit this section.
## Kritické soubory

- `/home/messa/code/gh/blockcopy/blockcopy.py` - hlavní změny
- `/home/messa/code/gh/blockcopy/tests/test_copy.py` - nové testy

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread add_metadata_plan.md

**Klíč k ověření:** `rsync --dry-run --itemize-changes` - prázdný výstup = soubory jsou shodné.

**Poznámka k nanosekudnám:** rsync od verze 3.1.3 podporuje `--modify-window=-1` pro porovnávání nanosekund. blockcopy používá `os.utime(ns=...)` který zachovává plnou přesnost, takže je kompatibilní i s tímto režimem.

Copilot AI Jan 26, 2026

Copy link

Choose a reason for hiding this comment

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

Spelling: "nanosekudnám" should be "nanosekundám".

Suggested change
**Poznámka k nanosekudnám:** rsync od verze 3.1.3 podporuje `--modify-window=-1` pro porovnávání nanosekund. blockcopy používá `os.utime(ns=...)` který zachovává plnou přesnost, takže je kompatibilní i s tímto režimem.
**Poznámka k nanosekundám:** rsync od verze 3.1.3 podporuje `--modify-window=-1` pro porovnávání nanosekund. blockcopy používá `os.utime(ns=...)` který zachovává plnou přesnost, takže je kompatibilní i s tímto režimem.

Copilot uses AI. Check for mistakes.
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.

3 participants