osbase/fat32: adopt structfs
Change the external interface of the FAT32 writer to take a
structfs.Tree instead of a FAT32-specific data structure. Producers of
file system data are no longer specific to FAT32.
With these changes, the blkio package becomes obsolete. The
LazyFileReader did not actually work as intended when used with
osbase/fat32, because fat32 copies data with io.CopyN and thus stops
reading before reaching EOF, so the LazyFileReader is never closed. The
new Blob interface requires the consumer to explicitly Open and Close.
Change-Id: I9a71a5f0bddf36ac38c656659e6dcfe520b88fb0
Reviewed-on: https://review.monogon.dev/c/monogon/+/4037
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/cli/metroctl/cmd_install_ssh.go b/metropolis/cli/metroctl/cmd_install_ssh.go
index efd1fd7..f0a5379 100644
--- a/metropolis/cli/metroctl/cmd_install_ssh.go
+++ b/metropolis/cli/metroctl/cmd_install_ssh.go
@@ -24,7 +24,7 @@
"google.golang.org/protobuf/proto"
"source.monogon.dev/go/net/ssh"
- "source.monogon.dev/osbase/fat32"
+ "source.monogon.dev/osbase/structfs"
)
var sshCmd = &cobra.Command{
@@ -130,14 +130,20 @@
return err
}
- barUploader := func(r fat32.SizedReader, targetPath string) {
+ barUploader := func(blob structfs.Blob, targetPath string) {
+ content, err := blob.Open()
+ if err != nil {
+ log.Fatalf("error while uploading %q: %v", targetPath, err)
+ }
+ defer content.Close()
+
bar := progressbar.DefaultBytes(
- r.Size(),
+ blob.Size(),
targetPath,
)
defer bar.Close()
- proxyReader := progressbar.NewReader(r, bar)
+ proxyReader := progressbar.NewReader(content, bar)
defer proxyReader.Close()
if err := conn.Upload(ctx, targetPath, &proxyReader); err != nil {