From 8a0f5249127dc2fab6d4d34611c0002b5cde2b8e Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 27 Jun 2018 17:20:38 +0200 Subject: indexamajig: Delete the temporary folder afterwards ... with extreme caution. --- src/im-sandbox.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/im-sandbox.c b/src/im-sandbox.c index 3dedf3f3..0794750f 100644 --- a/src/im-sandbox.c +++ b/src/im-sandbox.c @@ -848,6 +848,49 @@ static void try_status(struct sandbox *sb, time_t tNow) } +static void delete_temporary_folder(const char *tmpdir, int n_proc) +{ + int slot; + size_t len; + char *workerdir; + char *path; + + /* List of files which it's safe to delete */ + char *files[] = {"gmon.out", "mosflm.lp", "SUMMARY", "XDS.INP", + "xfel_001.img", "xfel_001.spt", "xfel.drx", + "xfel.felix", "xfel.gve", "xfel.ini", "xfel.log"}; + + /* Number of items in the above list */ + int n_files = 11; + + if ( n_proc > 99999 ) return; /* Paranoia */ + + len = strlen(tmpdir); + workerdir = calloc(len+32, 1); + path = calloc(len+64, 1); + if ( (workerdir == NULL) || (path == NULL) ) return; + + for ( slot=0; slotrunning); free(sb->last_response); free(sb->pids); - free(sb->tmpdir); STATUS("Final: %i images processed, %i had crystals (%.1f%%)," " %i crystals overall.\n", @@ -1073,6 +1115,9 @@ void create_sandbox(struct index_args *iargs, int n_proc, char *prefix, 100.0 * sb->shared->n_hadcrystals / sb->shared->n_processed, sb->shared->n_crystals); + delete_temporary_folder(sb->tmpdir, n_proc); + free(sb->tmpdir); + munmap(sb->shared, sizeof(struct sb_shm)); free(sb); } -- cgit v1.2.3