forked from TrueCloudLab/rclone
swift: Fix extra HEAD transaction when uploading a new file - fixes #2053
Also don't keep the swift.Headers as a pointer to a map, just use the map
This commit is contained in:
parent
6546b7e0b0
commit
5055b340da
1 changed files with 11 additions and 10 deletions
|
@ -148,7 +148,7 @@ type Object struct {
|
||||||
fs *Fs // what this object is part of
|
fs *Fs // what this object is part of
|
||||||
remote string // The remote path
|
remote string // The remote path
|
||||||
info swift.Object // Info from the swift object if known
|
info swift.Object // Info from the swift object if known
|
||||||
headers *swift.Headers // The object headers if known
|
headers swift.Headers // The object headers if known
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
|
@ -493,6 +493,7 @@ func (f *Fs) Put(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.
|
||||||
fs := &Object{
|
fs := &Object{
|
||||||
fs: f,
|
fs: f,
|
||||||
remote: src.Remote(),
|
remote: src.Remote(),
|
||||||
|
headers: swift.Headers{}, // Empty object headers to stop readMetaData being called
|
||||||
}
|
}
|
||||||
return fs, fs.Update(in, src, options...)
|
return fs, fs.Update(in, src, options...)
|
||||||
}
|
}
|
||||||
|
@ -657,7 +658,7 @@ func (o *Object) hasHeader(header string) (bool, error) {
|
||||||
}
|
}
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
_, isDynamicLargeObject := (*o.headers)[header]
|
_, isDynamicLargeObject := o.headers[header]
|
||||||
return isDynamicLargeObject, nil
|
return isDynamicLargeObject, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,7 +694,7 @@ func (o *Object) readMetaData() (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
o.info = info
|
o.info = info
|
||||||
o.headers = &h
|
o.headers = h
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -726,10 +727,10 @@ func (o *Object) SetModTime(modTime time.Time) error {
|
||||||
meta.SetModTime(modTime)
|
meta.SetModTime(modTime)
|
||||||
newHeaders := meta.ObjectHeaders()
|
newHeaders := meta.ObjectHeaders()
|
||||||
for k, v := range newHeaders {
|
for k, v := range newHeaders {
|
||||||
(*o.headers)[k] = v
|
o.headers[k] = v
|
||||||
}
|
}
|
||||||
// Include any other metadata from request
|
// Include any other metadata from request
|
||||||
for k, v := range *o.headers {
|
for k, v := range o.headers {
|
||||||
if strings.HasPrefix(k, "X-Object-") {
|
if strings.HasPrefix(k, "X-Object-") {
|
||||||
newHeaders[k] = v
|
newHeaders[k] = v
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue