summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@wirdorange.org>2013-01-22 23:49:38 +0000
committerOthmar Gsenger <otti@wirdorange.org>2013-01-22 23:49:38 +0000
commit49c65bac0ad0bf667f4ec27a21bebef2e848d5e7 (patch)
tree54b26f3a78fe09f6bc45f1da3b46bac914468f4d
parentadded detection of broken and missing downloads (diff)
bugfixed cronjob
-rwxr-xr-xcron/read_filesize_from_filesystem.pl19
1 files changed, 13 insertions, 6 deletions
diff --git a/cron/read_filesize_from_filesystem.pl b/cron/read_filesize_from_filesystem.pl
index a4bc86c..c68c324 100755
--- a/cron/read_filesize_from_filesystem.pl
+++ b/cron/read_filesize_from_filesystem.pl
@@ -4,6 +4,7 @@ use Cwd 'abs_path';
use File::Basename;
use local::db;
use File::Copy;
+use File::Path;
use config;
my %seen;
for my $dl (local::db::download->retrieve_all)
@@ -25,13 +26,19 @@ for my $dl (local::db::download->retrieve_all)
for my $category (keys %seen)
{
opendir(my $dh, $config::config{files_dir}.'/'.$category) || next;
- while(readdir $dh) {
- next if /^\.\.?$/;
- if (not $seen{$category}{$_})
+ while(my $file = readdir $dh) {
+ next if $file =~ /^\.\.?$/;
+ next if not $file;
+ if (not $seen{$category}{$file})
{
- #warn "invisible download ".$config::config{files_dir}."/$category/$_";
- mkdir($config::config{files_dir}."/broken/$category");
- move($config::config{files_dir}."/$category/$_",$config::config{files_dir}."/broken/$category/$_");
+ #warn "invisible download ".$config::config{files_dir}."/$category/$file";
+ if ($config::config{purge_broken})
+ {
+ rmtree($config::config{files_dir}."/$category/$file");
+ } else {
+ mkpath($config::config{files_dir}."/broken/$category");
+ move($config::config{files_dir}."/$category/$file",$config::config{files_dir}."/broken/$category/$file");
+ }
}
}
closedir $dh;