]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/stored.c
- Add check for df path for dvd_freespace
[bacula/bacula] / bacula / src / stored / stored.c
index b91718ed486885119280e360242e83625754ac9d..508b0abe454f018c486f6e1f4f2072cd16eca81a 100644 (file)
@@ -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.