cmd/bzzup: trim directory in the manifest entry path (#3299)

release/1.5
Aron Fischer 8 years ago committed by Felix Lange
parent 04edbb0703
commit 0d9a8207d6
  1. 4
      cmd/bzzup/main.go

@ -106,7 +106,7 @@ func (c *client) uploadFile(file string, fi os.FileInfo) (manifest, error) {
func (c *client) uploadDirectory(dir string) (manifest, error) {
dirm := manifest{}
prefix := filepath.ToSlash(dir) + "/"
prefix := filepath.ToSlash(filepath.Clean(dir)) + "/"
err := filepath.Walk(dir, func(path string, fi os.FileInfo, err error) error {
if err != nil || fi.IsDir() {
return err
@ -115,7 +115,7 @@ func (c *client) uploadDirectory(dir string) (manifest, error) {
return fmt.Errorf("path %s outside directory %s", path, dir)
}
entry, err := c.uploadFile(path, fi)
entry.Path = strings.TrimPrefix(filepath.ToSlash(path), prefix)
entry.Path = strings.TrimPrefix(filepath.ToSlash(filepath.Clean(path)), prefix)
dirm.Entries = append(dirm.Entries, entry)
return err
})

Loading…
Cancel
Save