Hi,
I had an issue where
nzbperl.pl was finding the nzb files before
they were completely written out. This caused nzbperl to fail in
parsing the xml and forget about the file. The main cause for this is
due to using nzbperl in daemon mode and copying files to the machine
it is on remotely via samba or even scp over my ISP as nzbperl sees
the files before the transfer is complete.
I fixed this quite awhile but thought others could use this patch.
It simply checks the modified date of the file instead of just the
existence of a file. So nzbperl will ignore the file until the
modified time is over 2 seconds ago, this allows for a slower
connection to full transfer the file before any parsing is done. I'm
using this on linux (ubuntu 9.10) so I'm not sure if it is portable
but any linux/unix like system should be fine.
Also, thanks to Jason for writing nzbperl in the first place.. I have
been using it for years.. I might have some future patches as I have a
couple other things I want to do... an enhancement for the remote port
summary.. and also a way to queue an nzb named the same as one already
downloaded but since removed from the file system.
-Brian
patch is simply:
--- orig/
nzbperl.pl 2006-03-01 01:46:10.000000000 -0400
+++
nzbperl.pl 2009-12-07 23:17:30.867202784 -0400
@@ -1029,7 +1029,8 @@
opendir(QDIR, $queuedir);
my @candidates = grep(/\.nzb$/, readdir(QDIR));
foreach my $file (@candidates){
- if( !defined($nzbfiles{'files'}->{$file})){ # not queued yet
+ my $mtime = time() - (stat($queuedir . "/" . $file))[9];
+ if( !defined($nzbfiles{'files'}->{$file}) && ($mtime > 2)){ # not
queued yet && last modified more than 2 seconds ago
statMsg("Queueing new nzb file found on disk: $file");
$nzbfiles{'files'}->{$file}->{'read'} = 0;
$retCt++;