summaryrefslogtreecommitdiff
path: root/process.pl
blob: 33a627946bdb1466101990c6739fe75735bd5e15 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/perl
use strict;
use Cwd 'abs_path';
use File::Basename;
use local::db;
use config;
my $process_path = dirname(abs_path($config::config{process})) or die "Couldn\'t determine process_path";
#print "$process_path\n";

$ENV{NZBPP_DIRECTORY} or die "missing argument download id";
my $dl_id = basename($ENV{NZBPP_DIRECTORY}) or die "missing argument download id";
my $dl = local::db::download->retrieve($dl_id) or die 'cannont find download';
$dl->processing(1);
$dl->update;
chdir($process_path);
my $return = system($config::config{process});
$return = $return >> 8 if $return;
$dl->completed(1);

my $du = "du -sm ".$config::config{files_dir}.'/'.$dl->category->name.'/'.$dl_id;
my $du_resp = `$du`;
my ($size) = $du_resp =~ /^(\d+)/; 
#warn $size;
$dl->size($size);
$dl->update;

exit $return;