From 452142d5eb2abe6540809f78e4d22249bef1af9c Mon Sep 17 00:00:00 2001 From: Illyoung Choi Date: Thu, 22 Aug 2024 16:15:18 -0700 Subject: [PATCH] use pointer of bytes.Buffer to get updates back --- fs/fs_bulk.go | 6 +++--- irods/fs/data_object_bulk.go | 4 ++-- irods/util/hash.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/fs_bulk.go b/fs/fs_bulk.go index f77ca01..ef834c9 100644 --- a/fs/fs_bulk.go +++ b/fs/fs_bulk.go @@ -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{} @@ -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 @@ -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 diff --git a/irods/fs/data_object_bulk.go b/irods/fs/data_object_bulk.go index ab9f0c8..f17027f 100644 --- a/irods/fs/data_object_bulk.go +++ b/irods/fs/data_object_bulk.go @@ -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() @@ -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", diff --git a/irods/util/hash.go b/irods/util/hash.go index 71ae81c..5b5319c 100644 --- a/irods/util/hash.go +++ b/irods/util/hash.go @@ -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()) @@ -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)