sub upload {
use strict;
use warnings;
use 5.010;
use Net::FTP;
use Path::Class;
my ($rvars, $rftp) = @_;
my %vars = %$rvars;
# prelims with server...see if we're able to do anything
$rftp->cwd("/pages/eh5v.files") or warn "cwd failed in main $!\n";
my $rlist = $rftp->ls();
say "remote list is @$rlist";
$rftp->binary or warn "binary failed$!\n";
# filter for filetypes
my @filetypes = qw/jpg jpeg png ogv mp4 m4v webm/;
my $pattern = join '|', map "($_)", @filetypes;
opendir my $eh, $vars{"to_vids"} or warn "can't open vids $!\n";
while (defined ($_ = readdir($eh))){
next if m/~$/;
next if -d;
next unless m/($pattern)/i;
my $full_path = file($vars{"to_vids"}, $_);
my $string_path = $full_path->stringify;
my $size_local = -s $string_path;
say "value for $_ is $size_local";
#find size on server
my $size_remote = $rftp->size($_) or warn "size query failed $! for $_\n";
say "size remote for $_ is $size_remote";
## control for upload cases
if (!defined($size_remote)) { say "Upload $_" };
if ($size_remote eq $size_local)
{
say "Sizes equal with $_. Overwrite? Default=n"
}
else
{
say "Sizes different with $_. Overwrite? Default=y"
};
}
closedir $eh;
return $rftp;
}
####
size query failed for stairs.webm
Use of uninitialized value $size_remote in concatenation (.) or string at template_stuff/html2.pm line 331.
Use of uninitialized value $size_remote in string eq at template_stuff/html2.pm line 336.
loading vids
remote list is . .. kitchen.jpg kitchen.m4v kitchen.webm stairs.jpg stairs.m4v
value for kitchen.jpg is 27261
size remote for kitchen.jpg is 27261
Sizes equal with kitchen.jpg. Overwrite? Default=n
value for kitchen.m4v is 19297258
size remote for kitchen.m4v is 19297258
Sizes equal with kitchen.m4v. Overwrite? Default=n
value for kitchen.webm is 12808479
size remote for kitchen.webm is 12808479
Sizes equal with kitchen.webm. Overwrite? Default=n
value for stairs.jpg is 99199
size remote for stairs.jpg is 99199
Sizes equal with stairs.jpg. Overwrite? Default=n
value for stairs.m4v is 41678290
size remote for stairs.m4v is 40860741
Sizes different with stairs.m4v. Overwrite? Default=y
value for stairs.webm is 30127462
size remote for stairs.webm is
Upload stairs.webm
Sizes different with stairs.webm. Overwrite? Default=y
####
my (undef,undef,undef,undef,undef,undef,undef,$size,
$atime,$mtime,$ctime,undef,undef)
= lstat($string_path);
say "File $string_path has $size bytes $mtime";
my $born_local = stat($string_path)->ctime );
my $size_local = stat($string_path)->size );
say "values for $_ are $born_local and $size_local";