0

Начальный коммит

This commit is contained in:
eleksir
2021-05-18 12:32:46 +03:00
commit 0c147086c0
29 changed files with 2534 additions and 0 deletions

2
test/test_file.txt Normal file
View File

@@ -0,0 +1,2 @@
lorem ipsum и всё такое, ну, вы знаете.
Съешь ещё этих французских булочек... да смотри, не подавись.

40
test/yad_file_info.pl Executable file
View File

@@ -0,0 +1,40 @@
#!/usr/bin/perl
use 5.018;
use strict;
use warnings;
use utf8;
use open qw (:std :utf8);
use English qw ( -no_match_vars );
use version; our $VERSION = qw (1.0);
my $workdir;
# сменим рабочий каталог
BEGIN {
use Cwd qw (chdir abs_path);
my @CWD = split /\//xms, abs_path ($PROGRAM_NAME);
if ($#CWD > 1) { $#CWD = $#CWD - 2; }
$workdir = join '/', @CWD;
chdir $workdir;
}
use lib ("$workdir/lib", "$workdir/vendor_perl", "$workdir/vendor_perl/lib/perl5");
use YadProxy::Conf qw (LoadConf);
use YadProxy::Lib qw (GetAccessToken);
use Yandex::Disk;
use Data::Dumper;
my $c = LoadConf ();
my $remote_dir = '';
my $file = 'test_file.txt';
if ($c->{remote_dir} && $c->{remote_dir} ne '') {
$remote_dir = $c->{remote_dir};
}
my $disk = Yandex::Disk->new ( -token => GetAccessToken );
say Dumper $disk->fileInfo ( -path => sprintf ("%s/%s", $remote_dir, $file));
__END__
# vim: set ft=perl noet ai ts=4 sw=4 sts=4:

32
test/yad_info.pl Executable file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/perl
use 5.018;
use strict;
use warnings;
use utf8;
use open qw (:std :utf8);
use English qw ( -no_match_vars );
use version; our $VERSION = qw (1.0);
my $workdir;
# сменим рабочий каталог
BEGIN {
use Cwd qw (chdir abs_path);
my @CWD = split /\//xms, abs_path ($PROGRAM_NAME);
if ($#CWD > 1) { $#CWD = $#CWD - 2; }
$workdir = join '/', @CWD;
chdir $workdir;
}
use lib ("$workdir/lib", "$workdir/vendor_perl", "$workdir/vendor_perl/lib/perl5");
use YadProxy::Lib qw (GetAccessToken);
use Yandex::Disk;
use Data::Dumper;
my $disk = Yandex::Disk->new ( -token => GetAccessToken() );
my $diskinfo = $disk->getDiskInfo();
say Dumper $diskinfo;
__END__
# vim: set ft=perl noet ai ts=4 sw=4 sts=4:

31
test/yad_list_all_files.pl Executable file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/perl
use 5.018;
use strict;
use warnings;
use utf8;
use open qw (:std :utf8);
use English qw ( -no_match_vars );
use version; our $VERSION = qw (1.0);
my $workdir;
# сменим рабочий каталог
BEGIN {
use Cwd qw (chdir abs_path);
my @CWD = split /\//xms, abs_path ($PROGRAM_NAME);
if ($#CWD > 1) { $#CWD = $#CWD - 2; }
$workdir = join '/', @CWD;
chdir $workdir;
}
use lib ("$workdir/lib", "$workdir/vendor_perl", "$workdir/vendor_perl/lib/perl5");
use YadProxy::Lib qw (GetAccessToken);
use Yandex::Disk;
use Data::Dumper;
my $disk = Yandex::Disk->new ( -token => GetAccessToken );
say Dumper $disk->listAllFiles ();
__END__
# vim: set ft=perl noet ai ts=4 sw=4 sts=4:

32
test/yad_list_published.pl Executable file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/perl
use 5.018;
use strict;
use warnings;
use utf8;
use open qw (:std :utf8);
use English qw ( -no_match_vars );
use version; our $VERSION = qw (1.0);
my $workdir;
# сменим рабочий каталог
BEGIN {
use Cwd qw (chdir abs_path);
my @CWD = split /\//xms, abs_path ($PROGRAM_NAME);
if ($#CWD > 1) { $#CWD = $#CWD - 2; }
$workdir = join '/', @CWD;
chdir $workdir;
}
use lib ("$workdir/lib", "$workdir/vendor_perl", "$workdir/vendor_perl/lib/perl5");
use YadProxy::Lib qw (GetAccessToken);
use Yandex::Disk;
use Data::Dumper;
my $disk = Yandex::Disk->new( -token => GetAccessToken );
my $public = $disk->public();
say Dumper $public->listPublished();
__END__
# vim: set ft=perl noet ai ts=4 sw=4 sts=4:

44
test/yad_mkdir.pl Executable file
View File

@@ -0,0 +1,44 @@
#!/usr/bin/perl
use 5.018;
use strict;
use warnings;
use utf8;
use open qw (:std :utf8);
use English qw ( -no_match_vars );
use version; our $VERSION = qw (1.0);
my $workdir;
# сменим рабочий каталог
BEGIN {
use Cwd qw (chdir abs_path);
my @CWD = split /\//xms, abs_path ($PROGRAM_NAME);
if ($#CWD > 1) { $#CWD = $#CWD - 2; }
$workdir = join '/', @CWD;
chdir $workdir;
}
use lib ("$workdir/lib", "$workdir/vendor_perl", "$workdir/vendor_perl/lib/perl5");
use YadProxy::Conf qw (LoadConf);
use YadProxy::Lib qw (GetAccessToken);
use Yandex::Disk;
use Data::Dumper;
my $c = LoadConf ();
my $remote_dir = '/';
if ($c->{remote_dir} && $c->{remote_dir} ne '') {
$remote_dir = $c->{remote_dir};
$disk->createFolder (-path => $remote_dir, -recursive => 1) or do {
die "Невозможно создать каталог $c->{remote_dir} на Yandex.Диске";
};
}
my $disk = Yandex::Disk->new( -token => GetAccessToken );
$disk->createFolder(-path => 'myYaD/test', -recursive => 1);
say Dumper $disk->listFiles (-path => '/');
__END__
# vim: set ft=perl noet ai ts=4 sw=4 sts=4:

55
test/yad_upload_file.pl Executable file
View File

@@ -0,0 +1,55 @@
#!/usr/bin/perl
use 5.018;
use strict;
use warnings;
use utf8;
use open qw (:std :utf8);
use English qw ( -no_match_vars );
use version; our $VERSION = qw (1.0);
my $workdir;
# сменим рабочий каталог
BEGIN {
use Cwd qw (chdir abs_path);
my @CWD = split /\//xms, abs_path ($PROGRAM_NAME);
if ($#CWD > 1) { $#CWD = $#CWD - 2; }
$workdir = join '/', @CWD;
chdir $workdir;
}
use lib ("$workdir/lib", "$workdir/vendor_perl", "$workdir/vendor_perl/lib/perl5");
use File::Basename;
use YadProxy::Conf qw (LoadConf);
use YadProxy::Lib qw (GetAccessToken);
use Yandex::Disk;
use Data::Dumper;
my $c = LoadConf ();
my $remote_dir = '/';
my $file = 'test/test_file.txt';
my $disk = Yandex::Disk->new ( -token => GetAccessToken );
if ($c->{remote_dir} && $c->{remote_dir} ne '') {
$remote_dir = $c->{remote_dir};
$disk->createFolder (
-path => $remote_dir,
-recursive => 1
) or do {
die "Невозможно создать каталог $c->{remote_dir} на Yandex.Диске";
};
}
$disk->uploadFile (
-file => $file,
-remote_path => $remote_dir,
-overwrite => 1
) or die "Не могу зааплодить файл в каталог $remote_dir на Yandex.Диске";
say Dumper $disk->listFiles (-path =>$remote_dir);
__END__
# vim: set ft=perl noet ai ts=4 sw=4 sts=4:

41
test/yadproxy_dump_dircache.pl Executable file
View File

@@ -0,0 +1,41 @@
#!/usr/bin/perl
use 5.018;
use strict;
use warnings;
use utf8;
use open qw (:std :utf8);
use English qw ( -no_match_vars );
use version; our $VERSION = qw (1.0);
my $workdir;
# сменим рабочий каталог
BEGIN {
use Cwd qw (chdir abs_path);
my @CWD = split /\//xms, abs_path ($PROGRAM_NAME);
if ($#CWD > 1) { $#CWD = $#CWD - 2; }
$workdir = join '/', @CWD;
chdir $workdir;
}
use lib ("$workdir/lib", "$workdir/vendor_perl", "$workdir/vendor_perl/lib/perl5");
use CHI;
use CHI::Driver::BerkeleyDB;
use Data::Dumper;
use YadProxy::Conf qw (LoadConf);
my $c = LoadConf ();
my $index_dir = $c->{index_dir};
my $index_dirs = CHI->new (
driver => 'BerkeleyDB',
root_dir => $index_dir,
namespace => 'dirs'
);
say join "\n", $index_dirs->get_keys ();
__END__
# vim: set ft=perl noet ai ts=4 sw=4 sts=4: