Skip to content

Commit

Permalink
use pointer of bytes.Buffer to get updates back
Browse files Browse the repository at this point in the history
  • Loading branch information
iychoi committed Aug 22, 2024
1 parent 0889140 commit 452142d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions fs/fs_bulk.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (fs *FileSystem) DownloadFileResumable(irodsPath string, resource string, l
}

// DownloadFileToBuffer downloads a file to buffer
func (fs *FileSystem) DownloadFileToBuffer(irodsPath string, resource string, buffer bytes.Buffer, verifyChecksum bool, callback common.TrackerCallBack) (*FileTransferResult, error) {
func (fs *FileSystem) DownloadFileToBuffer(irodsPath string, resource string, buffer *bytes.Buffer, verifyChecksum bool, callback common.TrackerCallBack) (*FileTransferResult, error) {
irodsSrcPath := util.GetCorrectIRODSPath(irodsPath)

fileTransferResult := &FileTransferResult{}
Expand Down Expand Up @@ -609,7 +609,7 @@ func (fs *FileSystem) UploadFile(localPath string, irodsPath string, resource st
}

// UploadFileFromBuffer uploads buffer data to irods
func (fs *FileSystem) UploadFileFromBuffer(buffer bytes.Buffer, irodsPath string, resource string, replicate bool, checksum bool, verifyChecksum bool, callback common.TrackerCallBack) (*FileTransferResult, error) {
func (fs *FileSystem) UploadFileFromBuffer(buffer *bytes.Buffer, irodsPath string, resource string, replicate bool, checksum bool, verifyChecksum bool, callback common.TrackerCallBack) (*FileTransferResult, error) {
irodsDestPath := util.GetCorrectIRODSPath(irodsPath)

irodsFilePath := irodsDestPath
Expand Down Expand Up @@ -891,7 +891,7 @@ func (fs *FileSystem) calculateLocalFileHash(localPath string) (types.ChecksumAl
}

// calculateBufferHash calculates buffer hash
func (fs *FileSystem) calculateBufferHash(buffer bytes.Buffer) (types.ChecksumAlgorithm, []byte, error) {
func (fs *FileSystem) calculateBufferHash(buffer *bytes.Buffer) (types.ChecksumAlgorithm, []byte, error) {
checksumAlg := types.GetChecksumAlgorithm(fs.account.DefaultHashScheme)
if checksumAlg == types.ChecksumAlgorithmUnknown {
checksumAlg = defaultChecksumAlgorithm
Expand Down
4 changes: 2 additions & 2 deletions irods/fs/data_object_bulk.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func CloseDataObjectReplica(conn *connection.IRODSConnection, handle *types.IROD
}

// UploadDataObjectFromBuffer put a data object to the iRODS path from buffer
func UploadDataObjectFromBuffer(session *session.IRODSSession, buffer bytes.Buffer, irodsPath string, resource string, replicate bool, keywords map[common.KeyWord]string, callback common.TrackerCallBack) error {
func UploadDataObjectFromBuffer(session *session.IRODSSession, buffer *bytes.Buffer, irodsPath string, resource string, replicate bool, keywords map[common.KeyWord]string, callback common.TrackerCallBack) error {
// use default resource when resource param is empty
if len(resource) == 0 {
account := session.GetAccount()
Expand Down Expand Up @@ -396,7 +396,7 @@ func UploadDataObjectParallel(session *session.IRODSSession, localPath string, i
}

// DownloadDataObjectToBuffer downloads a data object at the iRODS path to buffer
func DownloadDataObjectToBuffer(session *session.IRODSSession, irodsPath string, resource string, buffer bytes.Buffer, dataObjectLength int64, keywords map[common.KeyWord]string, callback common.TrackerCallBack) error {
func DownloadDataObjectToBuffer(session *session.IRODSSession, irodsPath string, resource string, buffer *bytes.Buffer, dataObjectLength int64, keywords map[common.KeyWord]string, callback common.TrackerCallBack) error {
logger := log.WithFields(log.Fields{
"package": "fs",
"function": "DownloadDataObject",
Expand Down
4 changes: 2 additions & 2 deletions irods/util/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func HashLocalFile(sourcePath string, hashAlg string) ([]byte, error) {
}
}

func HashBuffer(buffer bytes.Buffer, hashAlg string) ([]byte, error) {
func HashBuffer(buffer *bytes.Buffer, hashAlg string) ([]byte, error) {
switch strings.ToLower(hashAlg) {
case strings.ToLower(string(types.ChecksumAlgorithmMD5)):
return GetHashBuffer(buffer, md5.New())
Expand Down Expand Up @@ -97,7 +97,7 @@ func GetHashLocalFile(sourcePath string, hashAlg hash.Hash) ([]byte, error) {
return sumBytes, nil
}

func GetHashBuffer(buffer bytes.Buffer, hashAlg hash.Hash) ([]byte, error) {
func GetHashBuffer(buffer *bytes.Buffer, hashAlg hash.Hash) ([]byte, error) {
_, err := hashAlg.Write(buffer.Bytes())
if err != nil {
return nil, xerrors.Errorf("failed to write: %w", err)
Expand Down

0 comments on commit 452142d

Please sign in to comment.