int rsMvDataObjToTrash (rsComm_t *rsComm, dataObjInp_t *dataObjInp, dataObjInfo_t **dataObjInfoHead) { int status; char trashPath[MAX_NAME_LEN]; dataObjCopyInp_t dataObjRenameInp; if (strstr ((*dataObjInfoHead)->dataType, BUNDLE_STR) != NULL) { return SYS_CANT_MV_BUNDLE_DATA_TO_TRASH; } if (getValByKey (&dataObjInp->condInput, DATA_ACCESS_KW) == NULL) { addKeyVal (&dataObjInp->condInput, DATA_ACCESS_KW, ACCESS_DELETE_OBJECT); } status = getDataObjInfo (rsComm, dataObjInp, dataObjInfoHead, ACCESS_DELETE_OBJECT, 0); if (status < 0) { rodsLog (LOG_NOTICE, "rsMvDataObjToTrash: getDataObjInfo error for %s. status = %d", dataObjInp->objPath, status); return (status); } status = chkPreProcDeleteRule (rsComm, dataObjInp, *dataObjInfoHead); if (status < 0) return status; #if 0 /* done in chkPreProcDeleteRule */ initReiWithDataObjInp (&rei, rsComm, dataObjInp); rei.doi = *dataObjInfoHead; status = applyRule ("acDataDeletePolicy", NULL, &rei, NO_SAVE_REI); if (status < 0 && status != NO_MORE_RULES_ERR && status != SYS_DELETE_DISALLOWED) { rodsLog (LOG_NOTICE, "rsMvDataObjToTrash: acDataDeletePolicy error for %s. status = %d", dataObjInp->objPath, status); return (status); } if (rei.status == SYS_DELETE_DISALLOWED) { rodsLog (LOG_NOTICE, "rsMvDataObjToTrash:disallowed for %s via DataDeletePolicy,status=%d", dataObjInp->objPath, rei.status); return (rei.status); } #endif status = rsMkTrashPath (rsComm, dataObjInp->objPath, trashPath); if (status < 0) { return (status); } memset (&dataObjRenameInp, 0, sizeof (dataObjRenameInp)); dataObjRenameInp.srcDataObjInp.oprType = dataObjRenameInp.destDataObjInp.oprType = RENAME_DATA_OBJ; rstrcpy (dataObjRenameInp.destDataObjInp.objPath, trashPath, MAX_NAME_LEN); rstrcpy (dataObjRenameInp.srcDataObjInp.objPath, dataObjInp->objPath, MAX_NAME_LEN); status = rsDataObjRename (rsComm, &dataObjRenameInp); while (status == CAT_NAME_EXISTS_AS_DATAOBJ || status == CAT_NAME_EXISTS_AS_COLLECTION || status == SYS_PHY_PATH_INUSE || getErrno (status) == EISDIR) { appendRandomToPath (dataObjRenameInp.destDataObjInp.objPath); status = rsDataObjRename (rsComm, &dataObjRenameInp); #if 0 if (status1 < 0) { rodsLog (LOG_ERROR, "rsMvDataObjToTrash: rsDataObjRename error for %s", dataObjRenameInp.destDataObjInp.objPath); } else { status = 0; } #endif } if (status < 0) { rodsLog (LOG_ERROR, "rsMvDataObjToTrash: rcDataObjRename error for %s, status = %d", dataObjRenameInp.destDataObjInp.objPath, status); return (status); } return (status); }
int rsMvDataObjToTrash( rsComm_t *rsComm, dataObjInp_t *dataObjInp, dataObjInfo_t **dataObjInfoHead ) { int status; char trashPath[MAX_NAME_LEN]; dataObjCopyInp_t dataObjRenameInp; if ( strstr( ( *dataObjInfoHead )->dataType, BUNDLE_STR ) != NULL ) { // JMC - backport 4658 return SYS_CANT_MV_BUNDLE_DATA_TO_TRASH; } if ( getValByKey( &dataObjInp->condInput, DATA_ACCESS_KW ) == NULL ) { addKeyVal( &dataObjInp->condInput, DATA_ACCESS_KW, ACCESS_DELETE_OBJECT ); } status = getDataObjInfo( rsComm, dataObjInp, dataObjInfoHead, ACCESS_DELETE_OBJECT, 0 ); if ( status < 0 ) { rodsLog( LOG_NOTICE, "rsMvDataObjToTrash: getDataObjInfo error for %s. status = %d", dataObjInp->objPath, status ); return status; } status = chkPreProcDeleteRule( rsComm, dataObjInp, *dataObjInfoHead ); if ( status < 0 ) { return status; } status = rsMkTrashPath( rsComm, dataObjInp->objPath, trashPath ); if ( status < 0 ) { return status; } memset( &dataObjRenameInp, 0, sizeof( dataObjRenameInp ) ); dataObjRenameInp.srcDataObjInp.oprType = dataObjRenameInp.destDataObjInp.oprType = RENAME_DATA_OBJ; rstrcpy( dataObjRenameInp.destDataObjInp.objPath, trashPath, MAX_NAME_LEN ); rstrcpy( dataObjRenameInp.srcDataObjInp.objPath, dataObjInp->objPath, MAX_NAME_LEN ); status = rsDataObjRename( rsComm, &dataObjRenameInp ); while ( status == CAT_NAME_EXISTS_AS_DATAOBJ || status == CAT_NAME_EXISTS_AS_COLLECTION || status == SYS_PHY_PATH_INUSE || getErrno( status ) == EISDIR ) { appendRandomToPath( dataObjRenameInp.destDataObjInp.objPath ); status = rsDataObjRename( rsComm, &dataObjRenameInp ); } if ( status < 0 ) { rodsLog( LOG_ERROR, "rsMvDataObjToTrash: rcDataObjRename error for %s, status = %d", dataObjRenameInp.destDataObjInp.objPath, status ); return status; } return status; }
int _rsDataObjUnlink (rsComm_t *rsComm, dataObjInp_t *dataObjUnlinkInp, dataObjInfo_t **dataObjInfoHead) { int status; int retVal = 0; dataObjInfo_t *tmpDataObjInfo, *myDataObjInfoHead; status = chkPreProcDeleteRule (rsComm, dataObjUnlinkInp, *dataObjInfoHead); if (status < 0) return status; #if 0 /* done in chkPreProcDeleteRule */ ruleExecInfo_t rei; initReiWithDataObjInp (&rei, rsComm, dataObjUnlinkInp); rei.doi = *dataObjInfoHead; status = applyRule ("acDataDeletePolicy", NULL, &rei, NO_SAVE_REI); if (status < 0 && status != NO_MORE_RULES_ERR && status != SYS_DELETE_DISALLOWED) { rodsLog (LOG_NOTICE, "_rsDataObjUnlink: acDataDeletePolicy error for %s. status = %d", dataObjUnlinkInp->objPath, status); return (status); } if (rei.status == SYS_DELETE_DISALLOWED) { rodsLog (LOG_NOTICE, "_rsDataObjUnlink:disallowed for %s via acDataDeletePolicy,stat=%d", dataObjUnlinkInp->objPath, rei.status); return (rei.status); } #endif myDataObjInfoHead = *dataObjInfoHead; if (strstr (myDataObjInfoHead->dataType, BUNDLE_STR) != NULL) { int numSubfiles; if (rsComm->proxyUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH) { return CAT_INSUFFICIENT_PRIVILEGE_LEVEL; } if (getValByKey (&dataObjUnlinkInp->condInput, REPL_NUM_KW) != NULL) { return SYS_CANT_MV_BUNDLE_DATA_BY_COPY; } numSubfiles = getNumSubfilesInBunfileObj (rsComm, myDataObjInfoHead->objPath); if (numSubfiles > 0) { if (getValByKey (&dataObjUnlinkInp->condInput, EMPTY_BUNDLE_ONLY_KW) != NULL) { /* not empty. Nothing yo do */ return 0; } else { status = _unbunAndStageBunfileObj (rsComm, dataObjInfoHead, NULL, 1); if (status < 0) { /* go ahead and unlink the obj if the phy file does not * exist or have problem untaring it */ if (getErrno (status) != EEXIST && getIrodsErrno (status) != SYS_TAR_STRUCT_FILE_EXTRACT_ERR) { rodsLogError (LOG_ERROR, status, "_rsDataObjUnlink:_unbunAndStageBunfileObj err for %s", myDataObjInfoHead->objPath); return (status); } } /* dataObjInfoHead may be outdated */ *dataObjInfoHead = NULL; status = getDataObjInfoIncSpecColl (rsComm, dataObjUnlinkInp, dataObjInfoHead); if (status < 0) return (status); } } } tmpDataObjInfo = *dataObjInfoHead; while (tmpDataObjInfo != NULL) { status = dataObjUnlinkS (rsComm, dataObjUnlinkInp, tmpDataObjInfo); if (status < 0) { if (retVal == 0) { retVal = status; } } if (dataObjUnlinkInp->specColl != NULL) /* do only one */ break; tmpDataObjInfo = tmpDataObjInfo->next; } if ((*dataObjInfoHead)->specColl == NULL) resolveDataObjReplStatus (rsComm, dataObjUnlinkInp); return (retVal); }
int _rsDataObjUnlink( rsComm_t *rsComm, dataObjInp_t *dataObjUnlinkInp, dataObjInfo_t **dataObjInfoHead ) { int status; int retVal = 0; dataObjInfo_t *tmpDataObjInfo, *myDataObjInfoHead; status = chkPreProcDeleteRule( rsComm, dataObjUnlinkInp, *dataObjInfoHead ); if ( status < 0 ) { return status; } myDataObjInfoHead = *dataObjInfoHead; if ( strstr( myDataObjInfoHead->dataType, BUNDLE_STR ) != NULL ) { // JMC - backport 4658 int numSubfiles; // JMC - backport 4552 if ( rsComm->proxyUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH ) { return CAT_INSUFFICIENT_PRIVILEGE_LEVEL; } if ( getValByKey( &dataObjUnlinkInp->condInput, REPL_NUM_KW ) != NULL ) { return SYS_CANT_MV_BUNDLE_DATA_BY_COPY; } // =-=-=-=-=-=-=- // JMC - backport 4552 numSubfiles = getNumSubfilesInBunfileObj( rsComm, myDataObjInfoHead->objPath ); if ( numSubfiles > 0 ) { if ( getValByKey( &dataObjUnlinkInp->condInput, EMPTY_BUNDLE_ONLY_KW ) != NULL ) { /* not empty. Nothing to do */ return 0; } else { status = _unbunAndStageBunfileObj( rsComm, dataObjInfoHead, &dataObjUnlinkInp->condInput, NULL, 1 ); if ( status < 0 ) { /* go ahead and unlink the obj if the phy file does not * exist or have problem untaring it */ if ( getErrno( status ) != EEXIST && getIrodsErrno( status ) != SYS_TAR_STRUCT_FILE_EXTRACT_ERR ) { rodsLogError( LOG_ERROR, status, "_rsDataObjUnlink:_unbunAndStageBunfileObj err for %s", myDataObjInfoHead->objPath ); return status; } } // status < 0 /* dataObjInfoHead may be outdated */ *dataObjInfoHead = NULL; status = getDataObjInfoIncSpecColl( rsComm, dataObjUnlinkInp, dataObjInfoHead ); if ( status < 0 ) { return status; } } // else } // if numSubfiles } // if strcmp // =-=-=-=-=-=-=- tmpDataObjInfo = *dataObjInfoHead; while ( tmpDataObjInfo != NULL ) { status = dataObjUnlinkS( rsComm, dataObjUnlinkInp, tmpDataObjInfo ); if ( status < 0 ) { if ( retVal == 0 ) { retVal = status; } } if ( dataObjUnlinkInp->specColl != NULL ) { /* do only one */ break; } tmpDataObjInfo = tmpDataObjInfo->next; } if ( ( *dataObjInfoHead )->specColl == NULL ) { resolveDataObjReplStatus( rsComm, dataObjUnlinkInp ); } return retVal; }