Fixed #1; Added purge option

This commit is contained in:
Deon George
2016-07-07 15:00:21 +10:00
parent 58d95525ca
commit fca8930837
4 changed files with 109 additions and 31 deletions

View File

@@ -439,14 +439,15 @@ int tsm_deletefile(dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaDa
extern int verbose;
dsInt16_t rc=0;
dsUint16_t reason=0;
dsmDelInfo *dInfoP;
dsmDelType dType;
dsmDelInfo delInfo;
struct matchone_cb_data cbdata;
dsmBool_t friendly=bFalse;
cbdata.numfound = 0;
rc = tsm_queryfile(dsmHandle,qType,tsm_matchone_cb,&cbdata,qaData,qbData,friendly);
/** Our purge function uses qtReserved8 - this will break in a future release of the API **/
rc = tsm_queryfile(dsmHandle,((qType == qtBackup || qType == qtReserved8) ? qtBackup : qtArchive),tsm_matchone_cb,&cbdata,qaData,qbData,friendly);
if (rc != DSM_RC_OK) {
return 0;
}
@@ -462,24 +463,35 @@ int tsm_deletefile(dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaDa
dType = dtArchive;
delArch daInfo;
daInfo.stVersion = delArchVersion;
daInfo.objId = cbdata.objId;
dInfoP = (dsmDelInfo *) &daInfo;
delInfo.archInfo.stVersion = delArchVersion;
delInfo.archInfo.objId = cbdata.objId;
} else if (qType == qtBackup) {
if (verbose)
fprintf(stderr,"%s: Deleting backup file %s\n",__func__,dsmObjnameToStr(*qbData.objName));
fprintf(stderr,"%s: Deleting backup file %s with id [%u-%u]\n",__func__,dsmObjnameToStr(*qbData.objName),cbdata.objId.hi,cbdata.objId.lo);
dType = dtBackup;
delBack dbInfo;
dbInfo.stVersion = delBackVersion;
dbInfo.objNameP = qbData.objName;
dbInfo.copyGroup = cbdata.copyGroup;
dsmObjName objName;
memset(&objName,0x00,sizeof(objName));
strcpy(objName.fs,qbData.objName->fs);
strcpy(objName.hl,qbData.objName->hl);
strcpy(objName.ll,qbData.objName->ll);
objName.objType = DSM_OBJ_FILE;
dInfoP = (dsmDelInfo *) &dbInfo;
delInfo.backInfo.stVersion = delBackVersion;
delInfo.backInfo.objNameP = &objName;
delInfo.backInfo.copyGroup = cbdata.copyGroup;
/** Our purge function uses qtReserved8 - this will break in a future release of the API **/
} else if (qType == qtReserved8) {
if (verbose)
fprintf(stderr,"%s: Purging backup file %s with id [%u-%u]\n",__func__,dsmObjnameToStr(*qbData.objName),cbdata.objId.hi,cbdata.objId.lo);
dType = dtBackupID;
delInfo.backIDInfo.stVersion = delBackIDVersion;
delInfo.backIDInfo.objId = cbdata.objId;
} else {
fprintf(stderr,"%s: UNKNOWN Type %d\n",__func__,qType);
@@ -492,7 +504,7 @@ int tsm_deletefile(dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaDa
return 0;
}
rc = dsmDeleteObj(dsmHandle,dType,*dInfoP);
rc = dsmDeleteObj(dsmHandle,dType,delInfo);
if (rc != DSM_RC_OK) {
printf("%s: dsmDeleteObj() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
return 0;