You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(remotefs): add DownloadFile helper to fetch files from hosts - #523
Adds remotefs.DownloadFile, the remote-to-local counterpart of Upload: atomic temp+rename, SHA-256 verified against the remote file, and the remote mode (or WithPermissions, which now applies to both) and mtime applied. Symlinks and other non-regular sources are rejected, since the remote stat describes the link itself; Windows file info now reports symbolic links so this holds there too.
upload.go is renamed to transfer.go in a separate commit now that it holds both directions.
DownloadFile is the counterpart of Upload: it writes to a temporary file
next to dst, verifies the bytes against the remote file's SHA-256, applies
the remote mode (or WithDownloadPermissions) and modification time, and
renames into place, so a failed transfer never leaves a truncated dst.
WithSkipUnchanged skips the transfer when dst already has the remote
file's size and modification time. Non-regular sources, including
symlinks, are rejected because the remote stat describes the link.
Refs #193
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
kke
changed the title
feat(remotefs): add DownloadFile for remote-to-local copies
feat(remotefs): add DownloadFile helper for fetching remote files
Nov 19, 2026
kke
changed the title
feat(remotefs): add DownloadFile helper for fetching remote files
feat(remotefs): add DownloadFile helper to fetch files from hosts
Nov 19, 2026
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Windows downloads fail because checksumming reopens an exclusively held source handle, and Windows file-info handling fails to identify symbolic links, bypassing their required rejection.
Adds remotefs.DownloadFile as the remote-to-local counterpart of Upload, addressing single-file downloads requested in #193 and #194. Directory transfers remain out of scope.
Changes:
Adds temporary-file downloads with SHA-256 verification and rename into place.
Supports remote permissions and modification times, permission overrides, and skipping unchanged files.
Consolidates transfer code and adds download tests and a usage example.
File
Description
remotefs/upload.go
Moves existing upload implementation to transfer.go.
remotefs/transfer.go
Houses uploads and introduces download functionality and options.
remotefs/transfer_test.go
Tests downloads, metadata, replacement, failures, and skip behavior.
…ymlinks
The Windows file daemon opens files without sharing, so WinFS.Sha256
failed with a sharing violation while DownloadFile still held the
source open. Close it, checking the error, before the checksum.
winFileInfo never set fs.ModeSymlink, so DownloadFile's symlink
rejection did not hold on Windows hosts. Stat and ReadDir now fetch
LinkType and Mode reports SymbolicLink entries as links.
Drop WithSkipUnchanged and WithDownloadPermissions: Upload has no skip
either, and DownloadFile now takes UploadOption so WithPermissions
serves both.
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The download path strips setuid, setgid, and sticky bits via Perm(), violating the promised source-mode preservation.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Preserve special permission bits when downloading files
remotefs/transfer.go:168
For a remote file with setuid, setgid, or sticky bits, Perm() silently strips those bits, so the default download does not preserve the source mode promised by DownloadFile and WithPermissions. Upload preserves the full source mode. Since non-regular files have already been rejected, retain stat.Mode() here so the subsequent chmod can preserve these bits too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
remotefs.DownloadFile, the remote-to-local counterpart ofUpload: atomic temp+rename, SHA-256 verified against the remote file, and the remote mode (orWithPermissions, which now applies to both) and mtime applied. Symlinks and other non-regular sources are rejected, since the remote stat describes the link itself; Windows file info now reports symbolic links so this holds there too.upload.gois renamed totransfer.goin a separate commit now that it holds both directions.Refs #193 (directory transfer not included).