diff --git a/fs/fs.go b/fs/fs.go index 78c4a33..ddcf576 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -990,3 +990,25 @@ func (fs *FileSystem) getDataObject(path string) (*Entry, error) { // otherwise, retrieve it and add it to cache return fs.getDataObjectNoCache(path) } + +// GetServerVersion returns server version info +func (fs *FileSystem) GetServerVersion() (*types.IRODSVersion, error) { + conn, err := fs.session.AcquireConnection() + if err != nil { + return nil, err + } + defer fs.session.ReturnConnection(conn) + + return conn.GetVersion(), nil +} + +// SupportParallelUpload returns if the server supports parallel upload +func (fs *FileSystem) SupportParallelUpload() bool { + conn, err := fs.session.AcquireConnection() + if err != nil { + return false + } + defer fs.session.ReturnConnection(conn) + + return conn.SupportParallUpload() +} diff --git a/irods/connection/connection.go b/irods/connection/connection.go index c73d84a..8cc47fc 100644 --- a/irods/connection/connection.go +++ b/irods/connection/connection.go @@ -93,6 +93,12 @@ func (conn *IRODSConnection) GetVersion() *types.IRODSVersion { return conn.serverVersion } +// SupportParallUpload checks if the server supports parallel upload +// available from 4.2.9 +func (conn *IRODSConnection) SupportParallUpload() bool { + return conn.serverVersion.HasHigherVersionThan(4, 2, 9) +} + func (conn *IRODSConnection) requiresCSNegotiation() bool { return conn.account.ClientServerNegotiation } diff --git a/irods/fs/data_object_bulk.go b/irods/fs/data_object_bulk.go index 7ad97dd..4179c75 100644 --- a/irods/fs/data_object_bulk.go +++ b/irods/fs/data_object_bulk.go @@ -27,7 +27,7 @@ func CloseDataObjectReplica(conn *connection.IRODSConnection, handle *types.IROD conn.Lock() defer conn.Unlock() - if !SupportParallUpload(conn) { + if !conn.SupportParallUpload() { // serial upload return fmt.Errorf("does not support close replica in current iRODS Version") } @@ -142,13 +142,6 @@ func UploadDataObject(session *session.IRODSSession, localPath string, irodsPath return replErr } -// SupportParallUpload checks if current server supports parallel upload -// available from 4.2.9 -func SupportParallUpload(conn *connection.IRODSConnection) bool { - irodsVersion := conn.GetVersion() - return irodsVersion.HasHigherVersionThan(4, 2, 9) -} - // UploadDataObjectParallel put a data object at the local path to the iRODS path in parallel // Partitions a file into n (taskNum) tasks and uploads in parallel func UploadDataObjectParallel(session *session.IRODSSession, localPath string, irodsPath string, resource string, taskNum int, replicate bool, callback common.TrackerCallBack) error { @@ -180,7 +173,7 @@ func UploadDataObjectParallel(session *session.IRODSSession, localPath string, i return fmt.Errorf("connection is nil or disconnected") } - if !SupportParallUpload(conn) { + if !conn.SupportParallUpload() { // serial upload return UploadDataObject(session, localPath, irodsPath, resource, replicate, callback) } @@ -380,7 +373,7 @@ func UploadDataObjectParallelInBlockAsync(session *session.IRODSSession, localPa return outputChan, errChan } - if !SupportParallUpload(conn) { + if !conn.SupportParallUpload() { // serial upload outputChan := make(chan int64, 1) errChan := make(chan error, 1) diff --git a/test/testcases/fs_api_test.go b/test/testcases/fs_api_test.go index e4ecf85..762ca90 100644 --- a/test/testcases/fs_api_test.go +++ b/test/testcases/fs_api_test.go @@ -856,7 +856,7 @@ func testParallelUploadAndDownloadDataObject(t *testing.T) { conn, err := sess.AcquireConnection() assert.NoError(t, err) - if !fs.SupportParallUpload(conn) { + if !conn.SupportParallUpload() { sess.ReturnConnection(conn) return }