How about an "Delete successfully sent" option for strorescu
Moderator: Moderator Team
How about an "Delete successfully sent" option for strorescu
Is there a possibility that someone could add an option to storescu that deletes successfully sent files?
We're using storescu to send some files and if they have been successfully sent/received then it would be nice if they could be automatically deleted after sending.
Would you consider adding such an option?
We're using storescu to send some files and if they have been successfully sent/received then it would be nice if they could be automatically deleted after sending.
Would you consider adding such an option?
-
- DCMTK Developer
- Posts: 2048
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
Re: How about an "Delete successfully sent" option for stror
Hi,
I think most people do this by writing a mini script around the storescu call. However, does not sound like a bad idea. Maybe something more general like the --exec-on-reception option in storescp makes sense, so you can start any script (including del/rm for deletion) after a file was sent successfully.
Do you have a proposal for a patch?
Best,
Michael
I think most people do this by writing a mini script around the storescu call. However, does not sound like a bad idea. Maybe something more general like the --exec-on-reception option in storescp makes sense, so you can start any script (including del/rm for deletion) after a file was sent successfully.
Do you have a proposal for a patch?
Best,
Michael
Re: How about an "Delete successfully sent" option for stror
I don't have a proposal for a patch, I'm just asking for a colleague that uses storescu in some scripted transfer jobs but he lacks the knowledge and I lack the time to implement our own solution.
Re: How about an "Delete successfully sent" option for stror
My colleague has now produced a patch to storescu.cc (current version from git) that adds a command-line switch that renames the files after having sent them.
If you'd like to add this code to the next release, then feel free to use this.
This simple change with the command to execute after a successful send hardcoded is faster than an approach with a command-line option where one may specify the command to execute like what is now present in storescp.
The code to the patch is as follows:
If you'd like to add this code to the next release, then feel free to use this.
This simple change with the command to execute after a successful send hardcoded is faster than an approach with a command-line option where one may specify the command to execute like what is now present in storescp.
The code to the patch is as follows:
Code: Select all
*** C:/Users/ggz/Desktop/storescu (1).cc Tue Aug 28 19:13:03 2012
--- C:/Users/ggz/Desktop/storescu.cc Tue Aug 28 19:13:03 2012
***************
*** 99,104 ****
--- 99,105 ----
static OFBool opt_scanDir = OFFalse;
static OFBool opt_recurse = OFFalse;
+ static OFBool opt_renameFile = OFFalse;
static const char *opt_scanPattern = "";
static OFBool opt_haltOnUnsuccessfulStore = OFTrue;
***************
*** 239,244 ****
--- 240,246 ----
#endif
cmd.addOption("--no-recurse", "-r", "do not recurse within directories (default)");
cmd.addOption("--recurse", "+r", "recurse within specified directories");
+ cmd.addOption("--file-rename", "+fr", "append done/bad to processed files");
cmd.addGroup("network options:");
cmd.addSubGroup("application entity titles:");
cmd.addOption("--aetitle", "-aet", 1, "[a]etitle: string", "set my calling AE title (default: " APPLICATIONTITLE ")");
***************
*** 411,416 ****
--- 413,420 ----
}
cmd.endOptionBlock();
+ if (cmd.findOption("--file-rename")) opt_renameFile = OFTrue;
+
if (cmd.findOption("--aetitle")) app.checkValue(cmd.getValue(opt_ourTitle));
if (cmd.findOption("--call")) app.checkValue(cmd.getValue(opt_peerTitle));
***************
*** 1458,1463 ****
--- 1462,1477 ----
}
}
+ static void
+ renameFile (const char *fname, const char *fext)
+ {
+ if (!opt_renameFile) return;
+ OFString fnewname(fname);
+ fnewname += fext;
+ if( rename(fname, fnewname.c_str()) != 0 )
+ OFLOG_WARN(storescuLogger, "cannot rename file '" << fname << "' to '" << fnewname.c_str() << "'");
+ }
+
static OFCondition
storeSCU(T_ASC_Association *assoc, const char *fname)
/*
***************
*** 1493,1498 ****
--- 1507,1513 ----
/* figure out if an error occured while the file was read*/
if (cond.bad()) {
OFLOG_ERROR(storescuLogger, "Bad DICOM file: " << fname << ": " << cond.text());
+ renameFile(fname,".bad");
return cond;
}
***************
*** 1505,1510 ****
--- 1520,1526 ----
if (!DU_findSOPClassAndInstanceInDataSet(dcmff.getDataset(),
sopClass, sopInstance, opt_correctUIDPadding)) {
OFLOG_ERROR(storescuLogger, "No SOP Class or Instance UID in file: " << fname);
+ renameFile(fname,".bad");
return DIMSE_BADDATA;
}
***************
*** 1530,1535 ****
--- 1546,1552 ----
if (!modalityName) modalityName = dcmFindNameOfUID(sopClass);
if (!modalityName) modalityName = "unknown SOP class";
OFLOG_ERROR(storescuLogger, "No presentation context for: (" << modalityName << ") " << sopClass);
+ renameFile(fname,".bad");
return DIMSE_NOVALIDPRESENTATIONCONTEXTID;
}
***************
*** 1572,1577 ****
--- 1589,1599 ----
*/
if (cond == EC_Normal && (rsp.DimseStatus == STATUS_Success || DICOM_WARNING_STATUS(rsp.DimseStatus))) {
unsuccessfulStoreEncountered = OFFalse;
+ renameFile(fname,".done");
+ }
+ else
+ {
+ renameFile(fname,".bad");
}
/* remember the response's status for later transmissions of data */
Re: How about an "Delete successfully sent" option for stror
I'd like to kindly ask if this patch could be considered for integration into the official development repository, as it has proven itself as a versatile addition to the storescu.exe here in our in-house usage of storescu in script files.
I'm pretty sure others would benefit from this enhancement too.
I'm pretty sure others would benefit from this enhancement too.
-
- DCMTK Developer
- Posts: 2048
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
Re: How about an "Delete successfully sent" option for stror
Hi,
thank you for the patch. I will add it to our bug/feature tracker with normal priority. Thus it can take some time until we integrate it, but I like the general idea behind the patch.
Best,
Michael
thank you for the patch. I will add it to our bug/feature tracker with normal priority. Thus it can take some time until we integrate it, but I like the general idea behind the patch.
Best,
Michael
Re: How about an "Delete successfully sent" option for stror
So is the delete successfully sent or run a script at the end of storescu something that will be added in the feature? Im currently reading up on C++ now to try and add it myself but having no luck. Basically trying to combine features from SCP to SCU.
-
- DCMTK Developer
- Posts: 2048
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
Re: How about an "Delete successfully sent" option for stror
Hi,
so far this is not planned. If you want to provide a patch, however, you're welcome.
Best,
Michael
so far this is not planned. If you want to provide a patch, however, you're welcome.
Best,
Michael
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 1 guest