Reads Windows file shares under netclient's contract for slow, lossy links: retries, resume at the byte reached, no total cap (from agent-tools, AGT-85)
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Nelson 5d44848194
All checks were successful
Suite release / publish (push) Has been skipped
Suite release / deliver-prune (push) Has been skipped
Suite release / module (push) Successful in 22s
Suite release / build (none, ubuntu-latest) (ubuntu-latest, none) (push) Has been skipped
Suite release / deploy-image (push) Has been skipped
Suite release / reserve (push) Has been skipped
Suite release / check-build (none, ubuntu-latest) (ubuntu-latest, none) (push) Has been skipped
Suite release / check-package (push) Has been skipped
Suite release / finalize (push) Has been skipped
Suite release / reused-checks (push) Has been skipped
Suite release / scope (push) Successful in 17s
Suite release / deliver (push) Has been skipped
netfs moves in from agent-tools, on the netclient library (#1)
2026-11-29 22:53:34 -08:00
errors_other.go netfs moves in from agent-tools, on the netclient library (#1) 2026-11-29 22:53:34 -08:00
errors_windows.go netfs moves in from agent-tools, on the netclient library (#1) 2026-11-29 22:53:34 -08:00
go.mod netfs moves in from agent-tools, on the netclient library (#1) 2026-11-29 22:53:34 -08:00
go.sum netfs moves in from agent-tools, on the netclient library (#1) 2026-11-29 22:53:34 -08:00
netfs.go netfs moves in from agent-tools, on the netclient library (#1) 2026-11-29 22:53:34 -08:00
netfs_windows_test.go netfs moves in from agent-tools, on the netclient library (#1) 2026-11-29 22:53:34 -08:00
README.md netfs moves in from agent-tools, on the netclient library (#1) 2026-11-29 22:53:34 -08:00

netfs

Reads files on Windows file shares (\\NelsonNAS\files, and a drive mapped to one, such as S:) under netclient's contract for slow, lossy links. Over hotel Wi-Fi SMB answers a read with "An unexpected network error occurred" when the read would work a moment later.

  • No total-duration cap: an operation that keeps working is never failed for time.
  • A transient network failure (the SMB and network errnos, never not-found or access denied) is retried with netclient's backoff, given up after 10 minutes without progress.
  • ReadFile reads in chunks and after a failure reopens the file and carries on at the byte it reached, only while the file's size and modification time are those it started with.
  • Only operations safe to repeat are retried: reading, stat, listing, globbing and walking. WriteFile writes once.
  • Once a server has given up, later operations on it are tried once until one succeeds, so a share that is down costs a run one budget, not one per file.

Local paths go through the same calls and are made once, as os would make them.

It was agent-tools' netfs package until shared packages got repositories of their own (AGT-85, AHT-258).

Using it

require forgejo.romaine.life/romaine-life/netfs v0.1.0
import "forgejo.romaine.life/romaine-life/netfs"

share := netfs.New(netfs.Options{Log: logLine}) // a nil Log writes to stderr
data, err := share.ReadFile(`\\NelsonNAS\files\tools\manifest.json`)

Testing

go test ./...; the share tests are Windows-only and use fake errnos, so they need no share.

Shipping

A library: the release-module topic in pipeline-templates' fleet.json tags each merge that changes the code, and every fleet repository whose go.mod requires it gets a take-up. Forgejo pushes it to its public GitHub copy, which proxy.golang.org serves to builds outside CI.