RT#18834 Cacti integration [schema history fix and cleanup refactor]
authorJonathan Prykop <jonathan@freeside.biz>
Mon, 13 Apr 2015 22:59:12 +0000 (17:59 -0500)
committerJonathan Prykop <jonathan@freeside.biz>
Mon, 13 Apr 2015 22:59:12 +0000 (17:59 -0500)
FS/FS/Cron/cacti_cleanup.pm [deleted file]
FS/FS/Cron/cleanup.pm
FS/FS/Schema.pm
FS/bin/freeside-daily

diff --git a/FS/FS/Cron/cacti_cleanup.pm b/FS/FS/Cron/cacti_cleanup.pm
deleted file mode 100644 (file)
index f862627..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-package FS::Cron::cacti_cleanup;
-use base 'Exporter';
-use vars '@EXPORT_OK';
-
-use FS::Record qw( qsearch );
-use Data::Dumper;
-
-@EXPORT_OK = qw( cacti_cleanup );
-
-sub cacti_cleanup {
-  foreach my $export (qsearch({
-    'table' => 'part_export',
-    'hashref' => { 'exporttype' => 'cacti' }
-  })) {
-    $export->cleanup;
-  }
-}
-
-1;
index 4c5cff2..6ec4013 100644 (file)
@@ -2,8 +2,9 @@ package FS::Cron::cleanup;
 use base 'Exporter';
 use vars '@EXPORT_OK';
 use FS::queue;
+use FS::Record qw( qsearch );
 
-@EXPORT_OK = qw( cleanup );
+@EXPORT_OK = qw( cleanup cleanup_before_backup );
 
 # start janitor jobs
 sub cleanup {
@@ -15,4 +16,19 @@ sub cleanup {
   $job->insert('_JOB');
 }
 
+sub cleanup_before_backup {
+  #remove outdated cacti_page entries
+  foreach my $export (qsearch({
+    'table' => 'part_export',
+    'hashref' => { 'exporttype' => 'cacti' }
+  })) {
+    $export->cleanup;
+  }
+  #remove cache files
+  my $deldir = "$FS::UID::cache_dir/cache.$FS::UID::datasrc/";
+  unlink <${deldir}.invoice*>;
+  unlink <${deldir}.letter*>;
+  unlink <${deldir}.CGItemp*>;
+}
+
 1;
index 839a971..29bbf78 100644 (file)
@@ -203,7 +203,7 @@ sub dbdef_dist {
            && ! /^legacy_cust_history$/
            && ( ! /^queue(_arg|_depend|_stat)?$/ || ! $opt->{'queue-no_history'} )
            && ! $tables_hashref_torrus->{$_}
-           && ! /^cacti_graph$/
+           && ! /^cacti_page$/
          }
       $dbdef->tables
   ) {
index bf9f177..cb018d1 100755 (executable)
@@ -83,15 +83,9 @@ export_batch_submit(%opt);
 use FS::Cron::agent_email qw(agent_email);
 agent_email(%opt);
 
-#does nothing unless there are cacti imports
-#should run before backup, no need to backup cacti imports
-use FS::Cron::cacti_cleanup qw(cacti_cleanup);
-cacti_cleanup();
-
-my $deldir = "$FS::UID::cache_dir/cache.$FS::UID::datasrc/";
-unlink <${deldir}.invoice*>;
-unlink <${deldir}.letter*>;
-unlink <${deldir}.CGItemp*>;
+#clears out cacti imports & deletes select database cache files
+use FS::Cron::cleanup qw( cleanup cleanup_before_backup );
+cleanup_before_backup();
 
 #backup should be last
 #you can skip this just by not having the config
@@ -99,7 +93,6 @@ use FS::Cron::backup qw(backup);
 backup();
 
 #except we'd rather not start cleanup jobs until the backup is done
-use FS::Cron::cleanup qw(cleanup);
 cleanup();
 
 $log->info('finish');