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
This commit is contained in:
Janoš Guljaš
2018-08-10 16:12:55 +02:00
committed by Balint Gabor
parent 3ec5dda4d2
commit 6d1e292eef
10 changed files with 840 additions and 151 deletions

View File

@ -106,13 +106,18 @@ func (a *API) NewManifestWriter(ctx context.Context, addr storage.Address, quitC
}
// AddEntry stores the given data and adds the resulting key to the manifest
func (m *ManifestWriter) AddEntry(ctx context.Context, data io.Reader, e *ManifestEntry) (storage.Address, error) {
key, _, err := m.api.Store(ctx, data, e.Size, m.trie.encrypted)
if err != nil {
return nil, err
}
func (m *ManifestWriter) AddEntry(ctx context.Context, data io.Reader, e *ManifestEntry) (key storage.Address, err error) {
entry := newManifestTrieEntry(e, nil)
entry.Hash = key.Hex()
if data != nil {
key, _, err = m.api.Store(ctx, data, e.Size, m.trie.encrypted)
if err != nil {
return nil, err
}
entry.Hash = key.Hex()
}
if entry.Hash == "" {
return key, errors.New("missing entry hash")
}
m.trie.addEntry(entry, m.quitC)
return key, nil
}