diff options
author | Janoš Guljaš <janos@users.noreply.github.com> | 2018-08-10 22:12:55 +0800 |
---|---|---|
committer | Balint Gabor <balint.g@gmail.com> | 2018-08-10 22:12:55 +0800 |
commit | 6d1e292eefa70b5cb76cd03ff61fc6c4550d7c36 (patch) | |
tree | 3bcd5ab444bd7486a9011656c85baeee00216286 /cmd/swarm/upload.go | |
parent | 3ec5dda4d2dd0dec6d5bd465752f30e8f6ce208c (diff) | |
download | dexon-6d1e292eefa70b5cb76cd03ff61fc6c4550d7c36.tar.gz dexon-6d1e292eefa70b5cb76cd03ff61fc6c4550d7c36.tar.zst dexon-6d1e292eefa70b5cb76cd03ff61fc6c4550d7c36.zip |
Manifest cli fix and upload defaultpath only once (#17375)
* cmd/swarm: fix manifest subcommands and add tests
* cmd/swarm: manifest update: update default entry for non-encrypted uploads
* swarm/api: upload defaultpath file only once
* swarm/api/client: improve UploadDirectory default path handling
* cmd/swarm: support absolute and relative default path values
* cmd/swarm: fix a typo in test
* cmd/swarm: check encrypted uploads in manifest update tests
Diffstat (limited to 'cmd/swarm/upload.go')
-rw-r--r-- | cmd/swarm/upload.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/cmd/swarm/upload.go b/cmd/swarm/upload.go index 8ba0e7c5f..9eae2a3f8 100644 --- a/cmd/swarm/upload.go +++ b/cmd/swarm/upload.go @@ -98,6 +98,17 @@ func upload(ctx *cli.Context) { if !recursive { return "", errors.New("Argument is a directory and recursive upload is disabled") } + if defaultPath != "" { + // construct absolute default path + absDefaultPath, _ := filepath.Abs(defaultPath) + absFile, _ := filepath.Abs(file) + // make sure absolute directory ends with only one "/" + // to trim it from absolute default path and get relative default path + absFile = strings.TrimRight(absFile, "/") + "/" + if absDefaultPath != "" && absFile != "" && strings.HasPrefix(absDefaultPath, absFile) { + defaultPath = strings.TrimPrefix(absDefaultPath, absFile) + } + } return client.UploadDirectory(file, defaultPath, "", toEncrypt) } } else { |