mirror of
https://github.com/rclone/rclone.git
synced 2024-11-29 12:04:11 +08:00
pikpak: non-buffered hash calculation for local source files
This commit is contained in:
parent
56caab2033
commit
846c1aeed0
|
@ -1695,6 +1695,18 @@ func (o *Object) upload(ctx context.Context, in io.Reader, src fs.ObjectInfo, wi
|
||||||
|
|
||||||
// Calculate gcid; grabbed from package jottacloud
|
// Calculate gcid; grabbed from package jottacloud
|
||||||
var gcid string
|
var gcid string
|
||||||
|
if srcObj := fs.UnWrapObjectInfo(src); srcObj != nil && srcObj.Fs().Features().IsLocal {
|
||||||
|
// No buffering; directly calculate gcid from source
|
||||||
|
rc, err := srcObj.Open(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to open src: %w", err)
|
||||||
|
}
|
||||||
|
defer fs.CheckClose(rc, &err)
|
||||||
|
|
||||||
|
if gcid, err = calcGcid(rc, srcObj.Size()); err != nil {
|
||||||
|
return fmt.Errorf("failed to calculate gcid: %w", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// unwrap the accounting from the input, we use wrap to put it
|
// unwrap the accounting from the input, we use wrap to put it
|
||||||
// back on after the buffering
|
// back on after the buffering
|
||||||
var wrap accounting.WrapFn
|
var wrap accounting.WrapFn
|
||||||
|
@ -1707,6 +1719,7 @@ func (o *Object) upload(ctx context.Context, in io.Reader, src fs.ObjectInfo, wi
|
||||||
}
|
}
|
||||||
// Wrap the accounting back onto the stream
|
// Wrap the accounting back onto the stream
|
||||||
in = wrap(in)
|
in = wrap(in)
|
||||||
|
}
|
||||||
|
|
||||||
if !withTemp {
|
if !withTemp {
|
||||||
info, err := o.fs.upload(ctx, in, leaf, dirID, gcid, size, options...)
|
info, err := o.fs.upload(ctx, in, leaf, dirID, gcid, size, options...)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user