X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fstored%2Fstored.c;h=508b0abe454f018c486f6e1f4f2072cd16eca81a;hb=a038cf98053a0bd2b0cfcd073d911ef1bd09b7bc;hp=b91718ed486885119280e360242e83625754ac9d;hpb=1fa734016fd373dab3091f26e1571a5785e1fa9a;p=bacula%2Fbacula diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index b91718ed48..508b0abe45 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -33,6 +33,7 @@ /* Forward referenced functions */ void terminate_stored(int sig); static int check_resources(); +static void cleanup_old_files(); extern "C" void *device_initialization(void *arg); @@ -205,6 +206,9 @@ int main (int argc, char *argv[]) drop(uid, gid); + cleanup_old_files(); + + /* Ensure that Volume Session Time and Id are both * set and are both non-zero. */ @@ -442,6 +446,22 @@ static int check_resources() return OK; } +static void cleanup_old_files() +{ + POOLMEM *cleanup = get_pool_memory(PM_MESSAGE); + int len = strlen(me->working_directory); + pm_strcpy(cleanup, "/bin/rm -f "); + pm_strcat(cleanup, me->working_directory); + if (len > 0 && me->working_directory[len-1] != '/') { + pm_strcat(cleanup, "/"); + } + pm_strcat(cleanup, my_name); + pm_strcat(cleanup, "*.spool"); + run_program(cleanup, 0, NULL); + free_pool_memory(cleanup); +} + + /* * Here we attempt to init and open each device. This is done * once at startup in a separate thread.