use IO::Socket::INET;
use Getopt::Std;
use File::Basename;
-use Cwd qw'abs_path';
+use Cwd 'abs_path';
use Fcntl qw':flock :mode';
-use Digest::MD5 qw'md5_hex'; # encrypted ID / SID
-use Time::HiRes qw'time';
+use Digest::MD5 'md5_hex'; # encrypted ID / SID
+use Time::HiRes 'time';
# use Smart::Comments;
use constant k => 2**10;
use constant M => 2**20;
our ($FEXID,$FEXXX,$HOME);
our (%alias);
our $chunksize = 0;
-our $version = 20160328;
+our $version = 20160919;
our $_0 = $0;
our $DEBUG = $ENV{DEBUG};
Partner program fexget is for downloading. See: fexget -h
+fexsend stores the login data (server, user and auth-ID) in the file
+$HOME/.fex/id
+The format of this file is ([data] is optional):
+
+server-URL[!proxy[:port[:chunk-size]]
+e-mail-address
+auth-ID
+
For temporary usage of a HTTP proxy use:
$0 -P your_proxy:port:chunksize_in_MB file recipient
Example:
$_ = <STDIN>||'';
if (/^y/i) {
my $new = `wget -nv -O- http://fex.belwue.de/download/fexsend`;
- if ($new !~ /upgrade fexsend/) {
+ my $newversion = $1 if $new =~ /version = (\d+)/;
+ if ($new !~ /upgrade fexsend/ or not $newversion) {
die "$0: bad update\n";
}
- system qw'cp -aL',$_0,$_0.'_old';
+ if ($newversion <= $version) {
+ die "$0: no newer version\n";
+ }
+ $_0 = abs_path($_0);
+ system qw'rsync -a',$_0,$_0.'_old';
exit $? if $?;
open $_0,'>',$_0 or die "$0: cannot write $_0. - $!\n";
print {$_0} $new;
exec $_0,qw'-V .';
}
}
+ exit;
exit if "@ARGV" eq '.';
}
$sid = $id;
if ($port eq 443 or $proxy) {
+ return if $opt_d;
return if $features; # early return if we know enough
- $req = "OPTIONS /FEX HTTP/1.1";
- $req = "HEAD /index.html HTTP/1.1";
+ $req = "OPTIONS /FEX HTTP/1.1"; # does not work with (some) proxies
+ $req = "GET /SID HTTP/1.1"; # needed as FEATURES query
} else {
$req = "GET /SID HTTP/1.1";
}
sub fileid {
my $file = shift;
- my @s = stat($file);
+ my $dirmode = shift;
+ my @s = $dirmode ? lstat($file) : stat($file);
if (@s) {
return md5_hex($file.$s[0].$s[1].$s[7].$s[9]);
next if $file eq '..';
if ($file eq '.') {
$fmd .= fileid($dir);
+ } elsif (-l "$dir/$file") {
+ # hack for dangling symlinks: do not raise an error
+ $fmd .= fileid("$dir/$file",'dirmode');
} else {
$fmd .= fmd("$dir/$file");
}