diff --git a/cmd/camput/files.go b/cmd/camput/files.go index 899d92d59..08059b8e3 100644 --- a/cmd/camput/files.go +++ b/cmd/camput/files.go @@ -325,10 +325,12 @@ func (up *Uploader) uploadNode(n *node) (*client.PutResult, error) { m := schema.NewCommonFileMap(n.fullPath, fi) switch { case mode&os.ModeSymlink != 0: - // TODO(bradfitz): use VFS here; PopulateSymlinkMap uses os.Readlink directly. - if err := schema.PopulateSymlinkMap(m, n.fullPath); err != nil { + // TODO(bradfitz): use VFS here; not os.Readlink + target, err := os.Readlink(n.fullPath) + if err != nil { return nil, err } + m.SetSymlinkTarget(target) case mode&os.ModeDevice != 0: // including mode & os.ModeCharDevice fallthrough diff --git a/pkg/schema/schema.go b/pkg/schema/schema.go index 372a423ee..471b0cf08 100644 --- a/pkg/schema/schema.go +++ b/pkg/schema/schema.go @@ -525,18 +525,14 @@ func PopulateParts(m Map, size int64, parts []BytesPart) error { return nil } -func PopulateSymlinkMap(m Map, fileName string) error { +// SetSymlinkTarget sets m to be of type "symlink" and sets the symlink's target. +func (m Map) SetSymlinkTarget(target string) { m["camliType"] = "symlink" - target, err := os.Readlink(fileName) - if err != nil { - return err - } if utf8.ValidString(target) { m["symlinkTarget"] = target } else { m["symlinkTargetBytes"] = []uint8(target) } - return nil } func newBytes() Map {