f3c58174c4
downloads still need the old copy code because they aren't
parallel in the same way uploads are. revert all the code
that removed the parallel copy, only use the non-parallel
copy for uploads, and add back the parallelism and chunk
size flags and have them set the maximum concurrent pieces
flags to values based on each other when only one is set
for backwards compatibility.
mostly reverts 54ef1c8ca2
Change-Id: I8b5f62bf18a6548fa60865c6c61b5f34fbcec14c
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
// Copyright (C) 2021 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package ulfs
|
|
|
|
import (
|
|
"github.com/zeebo/errs"
|
|
|
|
"storj.io/storj/cmd/uplink/ulloc"
|
|
)
|
|
|
|
//
|
|
// read handles
|
|
//
|
|
|
|
// osMultiReadHandle implements MultiReadHandle for *os.Files.
|
|
func newOSMultiReadHandle(fh LocalBackendFile) (MultiReadHandle, error) {
|
|
fi, err := fh.Stat()
|
|
if err != nil {
|
|
return nil, errs.Wrap(err)
|
|
}
|
|
return NewGenericMultiReadHandle(fh, ObjectInfo{
|
|
Loc: ulloc.NewLocal(fh.Name()),
|
|
IsPrefix: false,
|
|
Created: fi.ModTime(), // TODO: os specific crtime
|
|
ContentLength: fi.Size(),
|
|
}), nil
|
|
}
|
|
|
|
//
|
|
// write handles
|
|
//
|
|
|
|
type fileGenericWriter struct {
|
|
fs LocalBackend
|
|
raw LocalBackendFile
|
|
}
|
|
|
|
func (f *fileGenericWriter) WriteAt(b []byte, off int64) (int, error) { return f.raw.WriteAt(b, off) }
|
|
func (f *fileGenericWriter) Commit() error { return f.raw.Close() }
|
|
func (f *fileGenericWriter) Abort() error {
|
|
return errs.Combine(
|
|
f.raw.Close(),
|
|
f.fs.Remove(f.raw.Name()),
|
|
)
|
|
}
|
|
|
|
func newOSMultiWriteHandle(fs LocalBackend, fh LocalBackendFile) MultiWriteHandle {
|
|
return NewGenericMultiWriteHandle(&fileGenericWriter{
|
|
fs: fs,
|
|
raw: fh,
|
|
})
|
|
}
|