From 66201dc89e286fe34a6e2c7e47cc2414405cb5ee Mon Sep 17 00:00:00 2001 From: Illyoung Choi Date: Wed, 14 Jun 2023 15:41:06 -0700 Subject: [PATCH] do not immediately return listing of objects when it meets empty rows, for post-process --- irods/fs/collection.go | 12 ++++++------ irods/fs/data_object.go | 19 ++++++++++--------- irods/fs/ticket.go | 12 ++++++------ irods/fs/usergroup.go | 12 ++++++------ 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/irods/fs/collection.go b/irods/fs/collection.go index e2a3d05..36a0f9a 100644 --- a/irods/fs/collection.go +++ b/irods/fs/collection.go @@ -181,7 +181,7 @@ func ListCollectionMeta(conn *connection.IRODSConnection, path string) ([]*types if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return metas, nil + break } return nil, xerrors.Errorf("received collection metadata query error: %w", err) } @@ -284,7 +284,7 @@ func ListCollectionAccesses(conn *connection.IRODSConnection, path string) ([]*t if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return accesses, nil + break } return nil, xerrors.Errorf("received collection access query error: %w", err) } @@ -385,7 +385,7 @@ func ListAccessesForSubCollections(conn *connection.IRODSConnection, path string if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return accesses, nil + break } return nil, xerrors.Errorf("received collection access query error: %w", err) } @@ -488,7 +488,7 @@ func ListSubCollections(conn *connection.IRODSConnection, path string) ([]*types if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return collections, nil + break } return nil, xerrors.Errorf("received collection query error: %w", err) } @@ -769,7 +769,7 @@ func SearchCollectionsByMeta(conn *connection.IRODSConnection, metaName string, if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return collections, nil + break } return nil, xerrors.Errorf("received collection query error: %w", err) } @@ -889,7 +889,7 @@ func SearchCollectionsByMetaWildcard(conn *connection.IRODSConnection, metaName if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return collections, nil + break } return nil, xerrors.Errorf("received collection query error: %w", err) } diff --git a/irods/fs/data_object.go b/irods/fs/data_object.go index ea80d74..c257b12 100644 --- a/irods/fs/data_object.go +++ b/irods/fs/data_object.go @@ -485,7 +485,7 @@ func ListDataObjects(conn *connection.IRODSConnection, collection *types.IRODSCo if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return dataObjects, nil + break } return nil, xerrors.Errorf("received data object query error: %w", err) } @@ -670,7 +670,7 @@ func ListDataObjectsMasterReplica(conn *connection.IRODSConnection, collection * if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return dataObjects, nil + break } return nil, xerrors.Errorf("received data object query error: %w", err) } @@ -783,6 +783,7 @@ func ListDataObjectsMasterReplica(conn *connection.IRODSConnection, collection * // merge data objects per file mergedDataObjectsMap := map[int64]*types.IRODSDataObject{} + for _, object := range dataObjects { existingObj, exists := mergedDataObjectsMap[object.ID] if exists { @@ -852,7 +853,7 @@ func ListDataObjectMeta(conn *connection.IRODSConnection, collection *types.IROD if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return metas, nil + break } return nil, xerrors.Errorf("received data object metadata query error: %w", err) } @@ -957,7 +958,7 @@ func ListDataObjectAccesses(conn *connection.IRODSConnection, collection *types. if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return accesses, nil + break } return nil, xerrors.Errorf("received data object access query error: %w", err) } @@ -1058,7 +1059,7 @@ func ListAccessesForDataObjects(conn *connection.IRODSConnection, collection *ty if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return accesses, nil + break } return nil, xerrors.Errorf("received data object access query error: %w", err) } @@ -1990,7 +1991,7 @@ func SearchDataObjectsByMeta(conn *connection.IRODSConnection, metaName string, if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return dataObjects, nil + break } return nil, xerrors.Errorf("received data object query error: %w", err) } @@ -2195,7 +2196,7 @@ func SearchDataObjectsMasterReplicaByMeta(conn *connection.IRODSConnection, meta if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return dataObjects, nil + break } return nil, xerrors.Errorf("received data object query error: %w", err) } @@ -2408,7 +2409,7 @@ func SearchDataObjectsByMetaWildcard(conn *connection.IRODSConnection, metaName if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return dataObjects, nil + break } return nil, xerrors.Errorf("received data object query error: %w", err) } @@ -2614,7 +2615,7 @@ func SearchDataObjectsMasterReplicaByMetaWildcard(conn *connection.IRODSConnecti if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return dataObjects, nil + break } return nil, xerrors.Errorf("received data object query error: %w", err) } diff --git a/irods/fs/ticket.go b/irods/fs/ticket.go index 4fe54ad..585cc61 100644 --- a/irods/fs/ticket.go +++ b/irods/fs/ticket.go @@ -539,7 +539,7 @@ func ListTicketsForDataObjects(conn *connection.IRODSConnection) ([]*types.IRODS if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return tickets, nil + break } return nil, xerrors.Errorf("received a ticket query error: %w", err) @@ -719,7 +719,7 @@ func ListTicketsForCollections(conn *connection.IRODSConnection) ([]*types.IRODS if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return tickets, nil + break } return nil, xerrors.Errorf("received a ticket query error: %w", err) @@ -884,7 +884,7 @@ func ListTicketsBasic(conn *connection.IRODSConnection) ([]*types.IRODSTicket, e if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return tickets, nil + break } return nil, xerrors.Errorf("received a ticket query error: %w", err) @@ -1038,7 +1038,7 @@ func ListTicketAllowedHosts(conn *connection.IRODSConnection, ticketID int64) ([ if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return hosts, nil + break } return nil, xerrors.Errorf("received a ticket restriction query error: %w", err) @@ -1114,7 +1114,7 @@ func ListTicketAllowedUserNames(conn *connection.IRODSConnection, ticketID int64 if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return usernames, nil + break } return nil, xerrors.Errorf("received a ticket restriction query error: %w", err) @@ -1190,7 +1190,7 @@ func ListTicketAllowedGroupNames(conn *connection.IRODSConnection, ticketID int6 if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return groupnames, nil + break } return nil, xerrors.Errorf("received a ticket restriction query error: %w", err) diff --git a/irods/fs/usergroup.go b/irods/fs/usergroup.go index f4d44ca..4306310 100644 --- a/irods/fs/usergroup.go +++ b/irods/fs/usergroup.go @@ -146,7 +146,7 @@ func ListGroupUsers(conn *connection.IRODSConnection, group string) ([]*types.IR if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return users, nil + break } return nil, xerrors.Errorf("received a group user query error: %w", err) } @@ -244,7 +244,7 @@ func ListGroups(conn *connection.IRODSConnection) ([]*types.IRODSUser, error) { if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return groups, nil + break } return nil, xerrors.Errorf("received a group query error: %w", err) } @@ -342,7 +342,7 @@ func ListUsers(conn *connection.IRODSConnection) ([]*types.IRODSUser, error) { if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return users, nil + break } return nil, xerrors.Errorf("received a user query error: %w", err) } @@ -437,7 +437,7 @@ func ListUserGroupNames(conn *connection.IRODSConnection, user string) ([]string if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return groups, nil + break } return nil, xerrors.Errorf("received a group query error: %w", err) } @@ -631,7 +631,7 @@ func ListUserResourceQuota(conn *connection.IRODSConnection, user string) ([]*ty if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return quota, nil + break } return nil, xerrors.Errorf("received a quota query error: %w", err) } @@ -848,7 +848,7 @@ func ListUserMeta(conn *connection.IRODSConnection, user string) ([]*types.IRODS if err != nil { if types.GetIRODSErrorCode(err) == common.CAT_NO_ROWS_FOUND { // empty - return metas, nil + break } return nil, xerrors.Errorf("received a user metadata query error: %w", err) }