summaryrefslogtreecommitdiff
path: root/cron
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@wirdorange.org>2011-03-31 19:05:23 +0000
committerOthmar Gsenger <otti@wirdorange.org>2011-03-31 19:05:23 +0000
commitd26fa8c1e0886c813de5364ee6570c860c6ce12c (patch)
tree418120693100150b0443d3d880f945aaa45a0d22 /cron
parentadded support for browsing by category (diff)
hopfully repaired this after backup loss
Diffstat (limited to 'cron')
-rwxr-xr-xcron/clean_database.pl11
-rwxr-xr-xcron/read_filesize_from_filesystem.pl16
-rwxr-xr-xcron/regen_quota.pl17
3 files changed, 44 insertions, 0 deletions
diff --git a/cron/clean_database.pl b/cron/clean_database.pl
new file mode 100755
index 0000000..f553515
--- /dev/null
+++ b/cron/clean_database.pl
@@ -0,0 +1,11 @@
+#!/usr/bin/perl
+use strict;
+use Cwd 'abs_path';
+use File::Basename;
+use local::db;
+use config;
+
+for my $dl (local::db::download->retrieve_all)
+{
+ $dl->delete if not -d $config::config{files_dir}.'/'.$dl->category->name.'/'.$dl->download_id;
+}
diff --git a/cron/read_filesize_from_filesystem.pl b/cron/read_filesize_from_filesystem.pl
new file mode 100755
index 0000000..702ddb4
--- /dev/null
+++ b/cron/read_filesize_from_filesystem.pl
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+use strict;
+use Cwd 'abs_path';
+use File::Basename;
+use local::db;
+use config;
+
+for my $dl (local::db::download->retrieve_all)
+{
+ my $du = "du -sm ".$config::config{files_dir}.'/'.$dl->category->name.'/'.$dl->download_id;
+ my $du_resp = `$du`;
+ my ($size) = $du_resp =~ /^(\d+)/;
+ # warn $size;
+ $dl->size($size);
+ $dl->update;
+}
diff --git a/cron/regen_quota.pl b/cron/regen_quota.pl
new file mode 100755
index 0000000..e582b30
--- /dev/null
+++ b/cron/regen_quota.pl
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+use strict;
+use Cwd 'abs_path';
+use File::Basename;
+use local::db;
+use config;
+
+for my $owner (local::db::owner->retrieve_all)
+{
+ my $sum =0;
+ for my $dl ($owner->download)
+ {
+ $sum+=$dl->size
+ }
+ $owner->quota_used($sum);
+ $owner->update
+}