mirror of https://github.com/perkeep/perkeep.git
camput: concurrent tagging
Change-Id: Ice7a77d030087648187c1c8ad37888a1a9f406ca
This commit is contained in:
parent
7e448fe05e
commit
ff382ceef5
|
@ -579,20 +579,34 @@ func (up *Uploader) uploadNodeRegularFile(n *node) (*client.PutResult, error) {
|
||||||
}
|
}
|
||||||
handleResult("node-permanode-contentattr", put, nil)
|
handleResult("node-permanode-contentattr", put, nil)
|
||||||
if tags := up.fileOpts.tags(); len(tags) > 0 {
|
if tags := up.fileOpts.tags(); len(tags) > 0 {
|
||||||
// TODO(mpl): do these claims concurrently, not in series
|
errch := make(chan error)
|
||||||
for _, tag := range tags {
|
for _, tag := range tags {
|
||||||
m := schema.NewAddAttributeClaim(permaNode.BlobRef, "tag", tag)
|
go func(tag string) {
|
||||||
m.SetClaimDate(claimTime)
|
m := schema.NewAddAttributeClaim(permaNode.BlobRef, "tag", tag)
|
||||||
// TODO(mpl): verify that SetClaimDate does modify the GPG signature date of the claim
|
m.SetClaimDate(claimTime)
|
||||||
signed, err := up.SignMap(m, claimTime)
|
// TODO(mpl): verify that SetClaimDate does modify the GPG signature date of the claim
|
||||||
if err != nil {
|
signed, err := up.SignMap(m, claimTime)
|
||||||
return nil, fmt.Errorf("Failed to sign tag claim for node %v: %v", n, err)
|
if err != nil {
|
||||||
|
errch <- fmt.Errorf("Failed to sign tag claim for node %v: %v", n, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
put, err := up.uploadString(signed)
|
||||||
|
if err != nil {
|
||||||
|
errch <- fmt.Errorf("Error uploading permanode's tag attribute %v for node %v: %v", tag, n, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
handleResult("node-permanode-tag", put, nil)
|
||||||
|
errch <- nil
|
||||||
|
}(tag)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _ = range tags {
|
||||||
|
if e := <-errch; e != nil && err == nil {
|
||||||
|
err = e
|
||||||
}
|
}
|
||||||
put, err := up.uploadString(signed)
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Error uploading permanode's tag attribute %v for node %v: %v", tag, n, err)
|
return nil, err
|
||||||
}
|
|
||||||
handleResult("node-permanode-tag", put, nil)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue