fs: rcat - use in memory object and Copy for more reliable transfers
This commit is contained in:
parent
7d15c33e42
commit
4b185355df
1 changed files with 3 additions and 11 deletions
|
@ -1622,17 +1622,8 @@ func Rcat(fdst Fs, dstFileName string, in io.ReadCloser, modTime time.Time) (dst
|
||||||
buf := make([]byte, Config.StreamingUploadCutoff)
|
buf := make([]byte, Config.StreamingUploadCutoff)
|
||||||
if n, err := io.ReadFull(trackingIn, buf); err == io.EOF || err == io.ErrUnexpectedEOF {
|
if n, err := io.ReadFull(trackingIn, buf); err == io.EOF || err == io.ErrUnexpectedEOF {
|
||||||
Debugf(fdst, "File to upload is small (%d bytes), uploading instead of streaming", n)
|
Debugf(fdst, "File to upload is small (%d bytes), uploading instead of streaming", n)
|
||||||
in := ioutil.NopCloser(bytes.NewReader(buf[:n]))
|
src := NewMemoryObject(dstFileName, modTime, buf[:n])
|
||||||
objInfo := NewStaticObjectInfo(dstFileName, modTime, int64(n), false, nil, nil)
|
return Copy(fdst, nil, dstFileName, src)
|
||||||
if Config.DryRun {
|
|
||||||
Logf("stdin", "Not uploading as --dry-run")
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
dst, err := fdst.Put(in, objInfo, hashOption)
|
|
||||||
if err != nil {
|
|
||||||
return dst, err
|
|
||||||
}
|
|
||||||
return dst, compare(dst)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make a new ReadCloser with the bits we've already read
|
// Make a new ReadCloser with the bits we've already read
|
||||||
|
@ -1673,6 +1664,7 @@ func Rcat(fdst Fs, dstFileName string, in io.ReadCloser, modTime time.Time) (dst
|
||||||
return dst, err
|
return dst, err
|
||||||
}
|
}
|
||||||
if !canStream {
|
if !canStream {
|
||||||
|
// copy dst (which is the local object we have just streamed to) to the remote
|
||||||
return Copy(fdst, nil, dstFileName, dst)
|
return Copy(fdst, nil, dstFileName, dst)
|
||||||
}
|
}
|
||||||
return dst, nil
|
return dst, nil
|
||||||
|
|
Loading…
Add table
Reference in a new issue