Use Mojo::SQLite instead of ORLite + update deps
This commit is contained in:
parent
413e13a801
commit
1646980c22
|
@ -1,7 +1,10 @@
|
|||
local/*
|
||||
files/*
|
||||
lufi.conf
|
||||
lufi.db
|
||||
*.db
|
||||
*.db-shm
|
||||
*.db-wal
|
||||
*.bak
|
||||
*.swp
|
||||
script/hypnotoad.pid
|
||||
stop-upload
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
Revision history for Lufi
|
||||
|
||||
0.03 2018-??-??
|
||||
- Use Mojo::SQLite instead of ORLite
|
||||
|
||||
0.02.2 2017-09-18
|
||||
- Fix cron tasks bug
|
||||
|
||||
|
|
2
Makefile
2
Makefile
|
@ -24,7 +24,7 @@ podcheck:
|
|||
podchecker lib/Lufi/DB/File.pm lib/Lufi/DB/Slice.pm
|
||||
|
||||
test:
|
||||
$(CARTON) $(REAL_LUFI) test
|
||||
$(CARTON) prove -l -f -o t/basic.t
|
||||
|
||||
clean:
|
||||
rm -rf lufi.db files/
|
||||
|
|
2
cpanfile
2
cpanfile
|
@ -28,5 +28,5 @@ feature 'postgresql', 'PostgreSQL support' => sub {
|
|||
requires 'Mojolicious::Plugin::PgURLHelper';
|
||||
};
|
||||
feature 'sqlite', 'SQLite support' => sub {
|
||||
requires 'ORLite';
|
||||
requires 'Mojo::SQLite', '>= 3.000';
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -31,6 +31,7 @@ sub startup {
|
|||
session_duration => 3600,
|
||||
allow_pwd_on_files => 0,
|
||||
dbtype => 'sqlite',
|
||||
db_path => 'lufi.db',
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
# vim:set sw=4 ts=4 sts=4 ft=perl expandtab:
|
||||
package Lufi::DB::File;
|
||||
use Mojo::Base -base;
|
||||
use Mojo::Collection;
|
||||
use Mojo::File;
|
||||
use Mojo::Collection 'c';
|
||||
use Lufi::DB::Slice;
|
||||
|
||||
has 'short';
|
||||
has 'deleted' => 0;
|
||||
|
@ -23,6 +25,7 @@ has 'slices' => sub {
|
|||
return Mojo::Collection->new();
|
||||
};
|
||||
has 'passwd';
|
||||
has 'record' => 0;
|
||||
has 'app';
|
||||
|
||||
=head1 NAME
|
||||
|
@ -160,6 +163,21 @@ sub delete {
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub write {
|
||||
my $c = shift;
|
||||
|
||||
if ($c->record) {
|
||||
$c->app->dbi->db->query('UPDATE files SET short = ?, deleted = ?, mediatype = ?, filename = ?, filesize = ?, counter = ?, delete_at_first_view = ?, delete_at_day = ?, created_at = ?, created_by = ?, last_access_at = ?, mod_token = ?, nbslices = ?, complete = ?, passwd = ? WHERE short = ?', $c->short, $c->deleted, $c->mediatype, $c->filename, $c->filesize, $c->counter, $c->delete_at_first_view, $c->delete_at_day, $c->created_at, $c->created_by, $c->last_access_at, $c->mod_token, $c->nbslices, $c->complete, $c->passwd, $c->short);
|
||||
} else {
|
||||
$c->app->dbi->db->query('INSERT INTO files (short, deleted, mediatype, filename, filesize, counter, delete_at_first_view, delete_at_day, created_at, created_by, last_access_at, mod_token, nbslices, complete, passwd) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $c->short, $c->deleted, $c->mediatype, $c->filename, $c->filesize, $c->counter, $c->delete_at_first_view, $c->delete_at_day, $c->created_at, $c->created_by, $c->last_access_at, $c->mod_token, $c->nbslices, $c->complete, $c->passwd);
|
||||
$c->record(1);
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
=head2 count_empty
|
||||
|
||||
=over 1
|
||||
|
@ -174,6 +192,14 @@ sub delete {
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub count_empty {
|
||||
my $c = shift;
|
||||
|
||||
return $c->app->dbi->db->query('SELECT count(short) AS count FROM files WHERE created_at IS NULL')->hashes->first->{count};
|
||||
}
|
||||
|
||||
=head2 already_exists
|
||||
|
||||
=over 1
|
||||
|
@ -188,6 +214,15 @@ sub delete {
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub already_exists {
|
||||
my $c = shift;
|
||||
my $short = shift;
|
||||
|
||||
return $c->app->dbi->db->query('SELECT count(short) AS count FROM files WHERE short = ?', $short)->hashes->first->{count};
|
||||
}
|
||||
|
||||
=head2 get_empty
|
||||
|
||||
=over 1
|
||||
|
@ -202,6 +237,16 @@ sub delete {
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub get_empty {
|
||||
my $c = shift;
|
||||
|
||||
my $r = $c->app->dbi->db->query('SELECT * FROM files WHERE created_at IS NULL')->hashes->shuffle->first;
|
||||
|
||||
return $c->_slurp($r)->created_at(time)->write;
|
||||
}
|
||||
|
||||
=head2 get_stats
|
||||
|
||||
=over 1
|
||||
|
@ -216,6 +261,18 @@ sub delete {
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub get_stats {
|
||||
my $c = shift;
|
||||
|
||||
my $files = $c->app->dbi->db->query('SELECT count(short) AS count FROM files WHERE created_at IS NOT null AND deleted = ?', 0)->hashes->first->{count};
|
||||
my $deleted = $c->app->dbi->db->query('SELECT count(short) AS count FROM files WHERE created_at IS NOT null AND deleted = ?', 1)->hashes->first->{count};
|
||||
my $empty = $c->app->dbi->db->query('SELECT count(short) AS count FROM files WHERE created_at IS null')->hashes->first->{count};
|
||||
|
||||
return { files => $files, deleted => $deleted, empty => $empty };
|
||||
}
|
||||
|
||||
=head2 from_short
|
||||
|
||||
=over 1
|
||||
|
@ -230,6 +287,21 @@ sub delete {
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub from_short {
|
||||
my $c = shift;
|
||||
my $short = shift;
|
||||
|
||||
my $r = $c->app->dbi->db->query('SELECT * FROM files WHERE short = ?', $short)->hashes;
|
||||
|
||||
if ($r->size) {
|
||||
return $c->_slurp($r->first)->record(1);
|
||||
} else {
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
||||
=head2 get_oldest_undeleted_files
|
||||
|
||||
=over 1
|
||||
|
@ -244,6 +316,26 @@ sub delete {
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub get_oldest_undeleted_files {
|
||||
my $c = shift;
|
||||
my $num = shift;
|
||||
|
||||
my @files;
|
||||
my $records = $c->app->dbi->db->query('SELECT * FROM files WHERE deleted = ? ORDER BY created_at ASC LIMIT ?', 0, $num)->hashes;
|
||||
$records->each(
|
||||
sub {
|
||||
my ($e, $num) = @_;
|
||||
my $i = Lufi::DB::File->new(app => $c->app);
|
||||
|
||||
push @files, $i->_slurp($e);
|
||||
}
|
||||
);
|
||||
|
||||
return c(@files);
|
||||
}
|
||||
|
||||
=head2 get_expired
|
||||
|
||||
=over 1
|
||||
|
@ -258,6 +350,27 @@ sub delete {
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub get_expired {
|
||||
my $c = shift;
|
||||
my $time = shift;
|
||||
|
||||
my @files;
|
||||
## Select only files expired since two days, to be sure that nobody is still downloading it
|
||||
my $records = $c->app->dbi->db->query('SELECT * FROM files WHERE deleted = ? AND ((delete_at_day + 2) * 86400) < (? - created_at) AND delete_at_day != 0', 0, $time)->hashes;
|
||||
$records->each(
|
||||
sub {
|
||||
my ($e, $num) = @_;
|
||||
my $i = Lufi::DB::File->new(app => $c->app);
|
||||
|
||||
push @files, $i->_slurp($e);
|
||||
}
|
||||
);
|
||||
|
||||
return c(@files);
|
||||
}
|
||||
|
||||
=head2 get_no_longer_viewed
|
||||
|
||||
=over 1
|
||||
|
@ -272,6 +385,26 @@ sub delete {
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub get_no_longer_viewed {
|
||||
my $c = shift;
|
||||
my $time = shift;
|
||||
|
||||
my @files;
|
||||
my $records = $c->app->dbi->db->query('SELECT * FROM files WHERE deleted = ? AND last_access_at < ?', 0, $time)->hashes;
|
||||
$records->each(
|
||||
sub {
|
||||
my ($e, $num) = @_;
|
||||
my $i = Lufi::DB::File->new(app => $c->app);
|
||||
|
||||
push @files, $i->_slurp($e);
|
||||
}
|
||||
);
|
||||
|
||||
return c(@files);
|
||||
}
|
||||
|
||||
=head2 delete_creator_before
|
||||
|
||||
=over 1
|
||||
|
@ -288,4 +421,67 @@ sub delete {
|
|||
|
||||
=cut
|
||||
|
||||
sub delete_creator_before {
|
||||
my $c = shift;
|
||||
my $separation = shift;
|
||||
|
||||
$c->app->dbi->db->query('UPDATE files SET created_by = NULL WHERE created_by IS NOT NULL AND created_at < ?', $separation);
|
||||
}
|
||||
|
||||
=head2 _slurp
|
||||
|
||||
=over 1
|
||||
|
||||
=item B<Usage> : C<$c-E<gt>_slurp>
|
||||
|
||||
=item B<Arguments> : none
|
||||
|
||||
=item B<Purpose> : put a database record's columns into the Lufi::DB::File object's attributes
|
||||
|
||||
=item B<Returns> : the Lufi::DB::File object
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub _slurp {
|
||||
my $c = shift;
|
||||
my $r = shift;
|
||||
|
||||
my $file;
|
||||
if (defined $r) {
|
||||
$file = $r;
|
||||
} else {
|
||||
my $files = $c->app->dbi->db->query('SELECT * FROM files WHERE short = ?', $c->short)->hashes;
|
||||
|
||||
if ($files->size) {
|
||||
$file = $files->first;
|
||||
}
|
||||
}
|
||||
|
||||
if ($file) {
|
||||
$c->short($file->{short});
|
||||
$c->deleted($file->{deleted});
|
||||
$c->mediatype($file->{mediatype});
|
||||
$c->filename($file->{filename});
|
||||
$c->filesize($file->{filesize});
|
||||
$c->counter($file->{counter});
|
||||
$c->delete_at_first_view($file->{delete_at_first_view});
|
||||
$c->delete_at_day($file->{delete_at_day});
|
||||
$c->created_at($file->{created_at});
|
||||
$c->created_by($file->{created_by});
|
||||
$c->last_access_at($file->{last_access_at});
|
||||
$c->mod_token($file->{mod_token});
|
||||
$c->nbslices($file->{nbslices});
|
||||
$c->complete($file->{complete});
|
||||
$c->passwd($file->{passwd});
|
||||
|
||||
$c->record(1) unless $c->record;
|
||||
}
|
||||
|
||||
$c->slices(Lufi::DB::Slice->new(app => $c->app)->get_slices_of_file($c->short));
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
# vim:set sw=4 ts=4 sts=4 ft=perl expandtab:
|
||||
package Lufi::DB::File::Pg;
|
||||
use Mojo::Base 'Lufi::DB::File';
|
||||
use Mojo::File;
|
||||
use Mojo::Collection 'c';
|
||||
use Lufi::DB::Slice;
|
||||
|
||||
has 'record' => 0;
|
||||
|
||||
sub new {
|
||||
my $c = shift;
|
||||
|
@ -15,163 +10,4 @@ sub new {
|
|||
return $c;
|
||||
}
|
||||
|
||||
sub write {
|
||||
my $c = shift;
|
||||
|
||||
if ($c->record) {
|
||||
$c->app->pg->db->query('UPDATE files SET short = ?, deleted = ?, mediatype = ?, filename = ?, filesize = ?, counter = ?, delete_at_first_view = ?, delete_at_day = ?, created_at = ?, created_by = ?, last_access_at = ?, mod_token = ?, nbslices = ?, complete = ?, passwd = ? WHERE short = ?', $c->short, $c->deleted, $c->mediatype, $c->filename, $c->filesize, $c->counter, $c->delete_at_first_view, $c->delete_at_day, $c->created_at, $c->created_by, $c->last_access_at, $c->mod_token, $c->nbslices, $c->complete, $c->passwd, $c->short);
|
||||
} else {
|
||||
$c->app->pg->db->query('INSERT INTO files (short, deleted, mediatype, filename, filesize, counter, delete_at_first_view, delete_at_day, created_at, created_by, last_access_at, mod_token, nbslices, complete, passwd) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $c->short, $c->deleted, $c->mediatype, $c->filename, $c->filesize, $c->counter, $c->delete_at_first_view, $c->delete_at_day, $c->created_at, $c->created_by, $c->last_access_at, $c->mod_token, $c->nbslices, $c->complete, $c->passwd);
|
||||
$c->record(1);
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
sub count_empty {
|
||||
my $c = shift;
|
||||
|
||||
return $c->app->pg->db->query('SELECT count(short) FROM files WHERE created_at IS NULL')->hashes->first->{count};
|
||||
}
|
||||
|
||||
sub already_exists {
|
||||
my $c = shift;
|
||||
my $short = shift;
|
||||
|
||||
return $c->app->pg->db->query('SELECT count(short) FROM files WHERE short = ?', $short)->hashes->first->{count};
|
||||
}
|
||||
|
||||
sub get_empty {
|
||||
my $c = shift;
|
||||
|
||||
my $r = $c->app->pg->db->query('SELECT * FROM files WHERE created_at IS NULL')->hashes->shuffle->first;
|
||||
|
||||
return $c->_slurp($r)->created_at(time)->write;
|
||||
}
|
||||
|
||||
sub get_stats {
|
||||
my $c = shift;
|
||||
|
||||
my $files = $c->app->pg->db->query('SELECT count(short) FROM files WHERE created_at IS NOT null AND deleted = false')->hashes->first->{count};
|
||||
my $deleted = $c->app->pg->db->query('SELECT count(short) FROM files WHERE created_at IS NOT null AND deleted = true')->hashes->first->{count};
|
||||
my $empty = $c->app->pg->db->query('SELECT count(short) FROM files WHERE created_at IS null')->hashes->first->{count};
|
||||
|
||||
return { files => $files, deleted => $deleted, empty => $empty };
|
||||
}
|
||||
|
||||
sub from_short {
|
||||
my $c = shift;
|
||||
my $short = shift;
|
||||
|
||||
my $r = $c->app->pg->db->query('SELECT * FROM files WHERE short = ?', $short)->hashes;
|
||||
|
||||
if ($r->size) {
|
||||
return $c->_slurp($r->first)->record(1);
|
||||
} else {
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
||||
sub get_oldest_undeleted_files {
|
||||
my $c = shift;
|
||||
my $num = shift;
|
||||
|
||||
my @files;
|
||||
my $records = $c->app->pg->db->query('SELECT * FROM files WHERE deleted = false ORDER BY created_at ASC LIMIT ?', $num)->hashes;
|
||||
$records->each(
|
||||
sub {
|
||||
my ($e, $num) = @_;
|
||||
my $i = Lufi::DB::File->new(app => $c->app);
|
||||
|
||||
push @files, $i->_slurp($e);
|
||||
}
|
||||
);
|
||||
|
||||
return c(@files);
|
||||
}
|
||||
|
||||
sub get_expired {
|
||||
my $c = shift;
|
||||
my $time = shift;
|
||||
|
||||
my @files;
|
||||
## Select only files expired since two days, to be sure that nobody is still downloading it
|
||||
my $records = $c->app->pg->db->query('SELECT * FROM files WHERE deleted = false AND ((delete_at_day + 2) * 86400) < (? - created_at) AND delete_at_day != 0', $time)->hashes;
|
||||
$records->each(
|
||||
sub {
|
||||
my ($e, $num) = @_;
|
||||
my $i = Lufi::DB::File->new(app => $c->app);
|
||||
|
||||
push @files, $i->_slurp($e);
|
||||
}
|
||||
);
|
||||
|
||||
return c(@files);
|
||||
}
|
||||
|
||||
sub get_no_longer_viewed {
|
||||
my $c = shift;
|
||||
my $time = shift;
|
||||
|
||||
my @files;
|
||||
my $records = $c->app->pg->db->query('SELECT * FROM files WHERE deleted = false AND last_access_at < ?', $time)->hashes;
|
||||
$records->each(
|
||||
sub {
|
||||
my ($e, $num) = @_;
|
||||
my $i = Lufi::DB::File->new(app => $c->app);
|
||||
|
||||
push @files, $i->_slurp($e);
|
||||
}
|
||||
);
|
||||
|
||||
return c(@files);
|
||||
}
|
||||
|
||||
sub delete_creator_before {
|
||||
my $c = shift;
|
||||
my $separation = shift;
|
||||
|
||||
$c->app->pg->db->query('UPDATE files SET created_by = NULL WHERE created_by IS NOT NULL AND created_at < ?', $separation);
|
||||
}
|
||||
|
||||
sub _slurp {
|
||||
my $c = shift;
|
||||
my $r = shift;
|
||||
|
||||
my $file;
|
||||
if (defined $r) {
|
||||
$file = $r;
|
||||
} else {
|
||||
my $files = $c->app->pg->db->query('SELECT * FROM files WHERE short = ?', $c->short)->hashes;
|
||||
|
||||
if ($files->size) {
|
||||
$file = $files->first;
|
||||
}
|
||||
}
|
||||
|
||||
if ($file) {
|
||||
$c->short($file->{short});
|
||||
$c->deleted($file->{deleted});
|
||||
$c->mediatype($file->{mediatype});
|
||||
$c->filename($file->{filename});
|
||||
$c->filesize($file->{filesize});
|
||||
$c->counter($file->{counter});
|
||||
$c->delete_at_first_view($file->{delete_at_first_view});
|
||||
$c->delete_at_day($file->{delete_at_day});
|
||||
$c->created_at($file->{created_at});
|
||||
$c->created_by($file->{created_by});
|
||||
$c->last_access_at($file->{last_access_at});
|
||||
$c->mod_token($file->{mod_token});
|
||||
$c->nbslices($file->{nbslices});
|
||||
$c->complete($file->{complete});
|
||||
$c->passwd($file->{passwd});
|
||||
|
||||
$c->record(1) unless $c->record;
|
||||
}
|
||||
|
||||
$c->slices(Lufi::DB::Slice->new(app => $c->app)->get_slices_of_file($c->short));
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
# vim:set sw=4 ts=4 sts=4 ft=perl expandtab:
|
||||
package Lufi::DB::File::SQLite;
|
||||
use Mojo::Base 'Lufi::DB::File';
|
||||
use Mojo::File;
|
||||
use Mojo::Collection 'c';
|
||||
use Lufi::DB::SQLite;
|
||||
use Lufi::DB::Slice;
|
||||
|
||||
has 'record';
|
||||
|
||||
sub new {
|
||||
my $c = shift;
|
||||
|
@ -17,172 +12,4 @@ sub new {
|
|||
return $c;
|
||||
}
|
||||
|
||||
sub write {
|
||||
my $c = shift;
|
||||
|
||||
if (defined $c->record) {
|
||||
$c->record->update(
|
||||
short => $c->short,
|
||||
deleted => $c->deleted,
|
||||
mediatype => $c->mediatype,
|
||||
filename => $c->filename,
|
||||
filesize => $c->filesize,
|
||||
counter => $c->counter,
|
||||
delete_at_first_view => $c->delete_at_first_view,
|
||||
delete_at_day => $c->delete_at_day,
|
||||
created_at => $c->created_at,
|
||||
created_by => $c->created_by,
|
||||
last_access_at => $c->last_access_at,
|
||||
mod_token => $c->mod_token,
|
||||
nbslices => $c->nbslices,
|
||||
complete => $c->complete,
|
||||
passwd => $c->passwd,
|
||||
);
|
||||
} else {
|
||||
my $record = Lufi::DB::SQLite::Files->create(
|
||||
short => $c->short,
|
||||
deleted => $c->deleted,
|
||||
mediatype => $c->mediatype,
|
||||
filename => $c->filename,
|
||||
filesize => $c->filesize,
|
||||
counter => $c->counter,
|
||||
delete_at_first_view => $c->delete_at_first_view,
|
||||
delete_at_day => $c->delete_at_day,
|
||||
created_at => $c->created_at,
|
||||
created_by => $c->created_by,
|
||||
last_access_at => $c->last_access_at,
|
||||
mod_token => $c->mod_token,
|
||||
nbslices => $c->nbslices,
|
||||
complete => $c->complete,
|
||||
passwd => $c->passwd,
|
||||
);
|
||||
$c->record($record);
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
sub count_empty {
|
||||
my $c = shift;
|
||||
|
||||
return Lufi::DB::SQLite::Files->count('WHERE created_at IS NULL');
|
||||
}
|
||||
|
||||
sub already_exists {
|
||||
my $c = shift;
|
||||
my $short = shift;
|
||||
|
||||
return Lufi::DB::SQLite::Files->count('WHERE short = ?', $short);
|
||||
}
|
||||
|
||||
sub get_empty {
|
||||
my $c = shift;
|
||||
|
||||
my @records = Lufi::DB::SQLite::Files->select('WHERE created_at IS NULL LIMIT 1');
|
||||
|
||||
return $c->record($records[0])->_slurp->created_at(time)->write;
|
||||
}
|
||||
|
||||
sub get_stats {
|
||||
my $c = shift;
|
||||
|
||||
my $files = Lufi::DB::SQLite::Files->count('WHERE created_at IS NOT null AND deleted = 0');
|
||||
my $deleted = Lufi::DB::SQLite::Files->count('WHERE created_at IS NOT null AND deleted = 1');
|
||||
my $empty = Lufi::DB::SQLite::Files->count('WHERE created_at IS null');
|
||||
|
||||
return { files => $files, deleted => $deleted, empty => $empty };
|
||||
}
|
||||
|
||||
sub from_short {
|
||||
my $c = shift;
|
||||
my $short = shift;
|
||||
|
||||
my @records = Lufi::DB::SQLite::Files->select('WHERE short = ?', $short);
|
||||
|
||||
if (scalar @records) {
|
||||
$c->record($records[0]);
|
||||
$c->_slurp;
|
||||
|
||||
return $c;
|
||||
} else {
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
||||
sub get_oldest_undeleted_files {
|
||||
my $c = shift;
|
||||
my $num = shift;
|
||||
|
||||
my @files = Lufi::DB::SQLite::Files->select('WHERE deleted = 0 ORDER BY created_at ASC LIMIT ?', $num);
|
||||
|
||||
return c(map { Lufi::DB::File->new(app => $c->app, record => $_) } @files);
|
||||
}
|
||||
|
||||
sub get_expired {
|
||||
my $c = shift;
|
||||
my $time = shift;
|
||||
|
||||
## Select only files expired since two days, to be sure that nobody is still downloading it
|
||||
my @files = Lufi::DB::SQLite::Files->select('WHERE deleted = 0 AND ((delete_at_day + 2) * 86400) < (? - created_at) AND delete_at_day != 0', $time);
|
||||
|
||||
return c(map { Lufi::DB::File->new(app => $c->app, record => $_) } @files);
|
||||
}
|
||||
|
||||
sub get_no_longer_viewed {
|
||||
my $c = shift;
|
||||
my $time = shift;
|
||||
|
||||
my @files = Lufi::DB::SQLite::Files->select('WHERE deleted = 0 AND last_access_at < ?', $time);
|
||||
|
||||
return c(map { Lufi::DB::File->new(app => $c->app, record => $_) } @files);
|
||||
}
|
||||
|
||||
sub delete_creator_before {
|
||||
my $c = shift;
|
||||
my $separation = shift;
|
||||
|
||||
Lufi::DB::SQLite->do(
|
||||
'UPDATE files SET created_by = NULL WHERE created_by IS NOT NULL AND created_at < ?',
|
||||
{},
|
||||
$separation
|
||||
);
|
||||
}
|
||||
|
||||
sub _slurp {
|
||||
my $c = shift;
|
||||
|
||||
my @files;
|
||||
if ($c->record) {
|
||||
@files = ($c->record);
|
||||
} elsif ($c->short) {
|
||||
@files = Lufi::DB::SQLite::Files->select('WHERE short = ?', $c->short);
|
||||
}
|
||||
|
||||
if (scalar @files) {
|
||||
my $file = $files[0];
|
||||
|
||||
$c->short($file->short);
|
||||
$c->deleted($file->deleted) if defined $file->deleted;
|
||||
$c->mediatype($file->mediatype) if defined $file->mediatype;
|
||||
$c->filename($file->filename) if defined $file->filename;
|
||||
$c->filesize($file->filesize) if defined $file->filesize;
|
||||
$c->counter($file->counter) if defined $file->counter;
|
||||
$c->delete_at_first_view($file->delete_at_first_view) if defined $file->delete_at_first_view;
|
||||
$c->delete_at_day($file->delete_at_day) if defined $file->delete_at_day;
|
||||
$c->created_at($file->created_at) if defined $file->created_at;
|
||||
$c->created_by($file->created_by) if defined $file->created_by;
|
||||
$c->last_access_at($file->last_access_at) if defined $file->last_access_at;
|
||||
$c->mod_token($file->mod_token) if defined $file->mod_token;
|
||||
$c->nbslices($file->nbslices) if defined $file->nbslices;
|
||||
$c->complete($file->complete) if defined $file->complete;
|
||||
$c->passwd($file->passwd) if defined $file->passwd;
|
||||
|
||||
$c->record($file) unless $c->record;
|
||||
}
|
||||
|
||||
$c->slices(Lufi::DB::Slice->new(app => $c->app)->get_slices_of_file($c->short));
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
# vim:set sw=4 ts=4 sts=4 ft=perl expandtab:
|
||||
package Lufi::DB::SQLite;
|
||||
use Mojolicious;
|
||||
use Mojo::File;
|
||||
use FindBin qw($Bin);
|
||||
|
||||
BEGIN {
|
||||
my $m = Mojolicious->new;
|
||||
my $cfile = Mojo::File->new($Bin, '..' , 'lufi.conf');
|
||||
if (defined $ENV{MOJO_CONFIG}) {
|
||||
$cfile = Mojo::File->new($ENV{MOJO_CONFIG});
|
||||
unless (-e $cfile->to_abs) {
|
||||
$cfile = Mojo::File->new($Bin, '..', $ENV{MOJO_CONFIG});
|
||||
}
|
||||
}
|
||||
our $config = $m->plugin('Config' =>
|
||||
{
|
||||
file => $cfile->to_abs->to_string,
|
||||
default => {
|
||||
db_path => 'lufi.db'
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
# Create database
|
||||
use ORLite {
|
||||
file => $config->{db_path},
|
||||
unicode => 1,
|
||||
create => sub {
|
||||
my $dbh = shift;
|
||||
$dbh->do(
|
||||
'CREATE TABLE files (
|
||||
short TEXT PRIMARY KEY,
|
||||
deleted INTEGER,
|
||||
mediatype TEXT,
|
||||
filename TEXT,
|
||||
filesize INTEGER,
|
||||
counter INTEGER,
|
||||
delete_at_first_view INTEGER,
|
||||
delete_at_day INTEGER,
|
||||
created_at INTEGER,
|
||||
created_by TEXT,
|
||||
last_access_at INTEGER,
|
||||
mod_token TEXT,
|
||||
nbslices INTEGER,
|
||||
complete INTEGER,
|
||||
passwd TEXT)'
|
||||
);
|
||||
$dbh->do(
|
||||
'CREATE TABLE slices (
|
||||
short TEXT,
|
||||
j INTEGER,
|
||||
path TEXT,
|
||||
FOREIGN KEY (short) REFERENCES files(short))'
|
||||
);
|
||||
$dbh->do(
|
||||
'CREATE INDEX slices_idx ON slices(short)'
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
1;
|
|
@ -1,10 +1,12 @@
|
|||
# vim:set sw=4 ts=4 sts=4 ft=perl expandtab:
|
||||
package Lufi::DB::Slice;
|
||||
use Mojo::Base -base;
|
||||
use Mojo::Collection 'c';
|
||||
|
||||
has 'short';
|
||||
has 'j';
|
||||
has 'path';
|
||||
has 'record' => 0;
|
||||
has 'app';
|
||||
|
||||
=head1 NAME
|
||||
|
@ -85,6 +87,21 @@ sub new {
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub write {
|
||||
my $c = shift;
|
||||
|
||||
if ($c->record) {
|
||||
$c->app->dbi->db->query('UPDATE slices SET short = ?, j = ?, path = ? WHERE short = ? AND j = ?', $c->short, $c->j, $c->path, $c->short, $c->j);
|
||||
} else {
|
||||
$c->app->dbi->db->query('INSERT INTO slices (short, j, path) VALUES (?, ?, ?)', $c->short, $c->j, $c->path);
|
||||
$c->record(1);
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
=head2 get_slices_of_file
|
||||
|
||||
=over 1
|
||||
|
@ -101,4 +118,64 @@ sub new {
|
|||
|
||||
=cut
|
||||
|
||||
sub get_slices_of_file {
|
||||
my $c = shift;
|
||||
my $short = shift;
|
||||
|
||||
my @slices;
|
||||
my $records = $c->app->dbi->db->query('SELECT * FROM slices WHERE short = ? ORDER BY j ASC', $short)->hashes;
|
||||
$records->each(
|
||||
sub {
|
||||
my ($e, $num) = @_;
|
||||
my $i = Lufi::DB::Slice->new(app => $c->app);
|
||||
|
||||
push @slices, $i->_slurp($e);
|
||||
}
|
||||
);
|
||||
|
||||
return c(@slices);
|
||||
}
|
||||
|
||||
=head2 _slurp
|
||||
|
||||
=over 1
|
||||
|
||||
=item B<Usage> : C<$c-E<gt>_slurp>
|
||||
|
||||
=item B<Arguments> : none
|
||||
|
||||
=item B<Purpose> : put a database record's columns into the Lufi::DB::Slice object's attributes
|
||||
|
||||
=item B<Returns> : the Lufi::DB::Slice object
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub _slurp {
|
||||
my $c = shift;
|
||||
my $r = shift;
|
||||
|
||||
my $slice;
|
||||
if (defined $r) {
|
||||
$slice = $r;
|
||||
} else {
|
||||
my $slices = $c->app->dbi->db->query('SELECT * FROM slices WHERE short = ? AND j = ?', $c->short, $c->j)->hashes;
|
||||
|
||||
if ($slices->size) {
|
||||
$slice = $slices->first;
|
||||
}
|
||||
}
|
||||
|
||||
if ($slice) {
|
||||
$c->short($slice->{short});
|
||||
$c->j($slice->{j});
|
||||
$c->path($slice->{path});
|
||||
|
||||
$c->record(1);
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
# vim:set sw=4 ts=4 sts=4 ft=perl expandtab:
|
||||
package Lufi::DB::Slice::Pg;
|
||||
use Mojo::Base 'Lufi::DB::Slice';
|
||||
use Mojo::Collection 'c';
|
||||
|
||||
has 'record' => 0;
|
||||
|
||||
sub new {
|
||||
my $c = shift;
|
||||
|
@ -13,61 +10,4 @@ sub new {
|
|||
return $c;
|
||||
}
|
||||
|
||||
sub write {
|
||||
my $c = shift;
|
||||
|
||||
if ($c->record) {
|
||||
$c->app->pg->db->query('UPDATE slices SET short = ?, j = ?, path = ? WHERE short = ? AND j = ?', $c->short, $c->j, $c->path, $c->short, $c->j);
|
||||
} else {
|
||||
$c->app->pg->db->query('INSERT INTO slices (short, j, path) VALUES (?, ?, ?)', $c->short, $c->j, $c->path);
|
||||
$c->record(1);
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
sub get_slices_of_file {
|
||||
my $c = shift;
|
||||
my $short = shift;
|
||||
|
||||
my @slices;
|
||||
my $records = $c->app->pg->db->query('SELECT * FROM slices WHERE short = ? ORDER BY j ASC', $short)->hashes;
|
||||
$records->each(
|
||||
sub {
|
||||
my ($e, $num) = @_;
|
||||
my $i = Lufi::DB::Slice->new(app => $c->app);
|
||||
|
||||
push @slices, $i->_slurp($e);
|
||||
}
|
||||
);
|
||||
|
||||
return c(@slices);
|
||||
}
|
||||
|
||||
sub _slurp {
|
||||
my $c = shift;
|
||||
my $r = shift;
|
||||
|
||||
my $slice;
|
||||
if (defined $r) {
|
||||
$slice = $r;
|
||||
} else {
|
||||
my $slices = $c->app->pg->db->query('SELECT * FROM slices WHERE short = ? AND j = ?', $c->short, $c->j)->hashes;
|
||||
|
||||
if ($slices->size) {
|
||||
$slice = $slices->first;
|
||||
}
|
||||
}
|
||||
|
||||
if ($slice) {
|
||||
$c->short($slice->{short});
|
||||
$c->j($slice->{j});
|
||||
$c->path($slice->{path});
|
||||
|
||||
$c->record(1);
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
# vim:set sw=4 ts=4 sts=4 ft=perl expandtab:
|
||||
package Lufi::DB::Slice::SQLite;
|
||||
use Mojo::Base 'Lufi::DB::Slice';
|
||||
use Lufi::DB::SQLite;
|
||||
use Mojo::Collection 'c';
|
||||
|
||||
has 'record';
|
||||
|
||||
sub new {
|
||||
my $c = shift;
|
||||
|
@ -16,44 +12,4 @@ sub new {
|
|||
return $c;
|
||||
}
|
||||
|
||||
sub write {
|
||||
my $c = shift;
|
||||
|
||||
if (defined $c->record) {
|
||||
$c->record->update(
|
||||
short => $c->short,
|
||||
j => $c->j,
|
||||
path => $c->path
|
||||
);
|
||||
} else {
|
||||
my $record = Lufi::DB::SQLite::Slices->create(
|
||||
short => $c->short,
|
||||
j => $c->j,
|
||||
path => $c->path
|
||||
);
|
||||
$c->record($record);
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
sub get_slices_of_file {
|
||||
my $c = shift;
|
||||
my $short = shift;
|
||||
|
||||
my @slices = Lufi::DB::SQLite::Slices->select('WHERE short = ? ORDER BY j ASC', $short);
|
||||
|
||||
return c(map { Lufi::DB::Slice->new(app => $c->app, record => $_) } @slices);
|
||||
}
|
||||
|
||||
sub _slurp {
|
||||
my $c = shift;
|
||||
|
||||
$c->short($c->record->short) if defined $c->record->short;
|
||||
$c->j($c->record->j) if defined $c->record->j;
|
||||
$c->path($c->record->path) if defined $c->record->path;
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -7,49 +7,66 @@ use Data::Entropy qw(entropy_source);
|
|||
sub register {
|
||||
my ($self, $app) = @_;
|
||||
|
||||
$app->plugin('PgURLHelper');
|
||||
# PgURL helper
|
||||
if ($app->config('dbtype') eq 'postgresql' || $app->config('dbtype') eq 'mysql') {
|
||||
$app->plugin('PgURLHelper');
|
||||
}
|
||||
|
||||
|
||||
if ($app->config('dbtype') eq 'postgresql') {
|
||||
use Mojo::Pg;
|
||||
$app->helper(pg => \&_pg);
|
||||
require Mojo::Pg;
|
||||
$app->helper(dbi => \&_pg);
|
||||
|
||||
# Database migration
|
||||
my $migrations = Mojo::Pg::Migrations->new(pg => $app->pg);
|
||||
my $migrations = Mojo::Pg::Migrations->new(pg => $app->dbi);
|
||||
if ($app->mode eq 'development' && $ENV{LUFI_DEV}) {
|
||||
$migrations->from_file('utilities/migrations_pg.sql')->migrate(0)->migrate(1);
|
||||
$migrations->from_file('utilities/migrations/pg.sql')->migrate(0)->migrate(1);
|
||||
} else {
|
||||
$migrations->from_file('utilities/migrations_pg.sql')->migrate(1);
|
||||
$migrations->from_file('utilities/migrations/pg.sql')->migrate(1);
|
||||
}
|
||||
} elsif ($app->config('dbtype') eq 'sqlite') {
|
||||
# SQLite database migration if needed
|
||||
use Lufi::DB::SQLite;
|
||||
my $columns = Lufi::DB::SQLite::Files->table_info;
|
||||
my $pwd_col = 0;
|
||||
foreach my $col (@{$columns}) {
|
||||
$pwd_col = 1 if $col->{name} eq 'passwd';
|
||||
require Mojo::SQLite;
|
||||
$app->helper(dbi => \&_sqlite);
|
||||
|
||||
# Database migration
|
||||
# Have to create $sql before using its migrations attribute, otherwise, it won't work
|
||||
my $sql = $app->dbi;
|
||||
my $migrations = $sql->migrations;
|
||||
if ($app->mode eq 'development' && $ENV{LUFI_DEV}) {
|
||||
$migrations->from_file('utilities/migrations/sqlite.sql')->migrate(0)->migrate(1);
|
||||
} else {
|
||||
$migrations->from_file('utilities/migrations/sqlite.sql')->migrate(1);
|
||||
}
|
||||
unless ($pwd_col) {
|
||||
Lufi::DB::SQLite->do('ALTER TABLE files ADD COLUMN passwd TEXT;');
|
||||
my $columns = $app->dbi->db->query('PRAGMA table_info(files)')->hashes;
|
||||
if ($columns->size == 14) { # Missing passwd column
|
||||
$app->dbi->db->query('ALTER TABLE files ADD COLUMN passwd TEXT');
|
||||
}
|
||||
}
|
||||
|
||||
$app->helper(provisioning => \&_provisioning);
|
||||
$app->helper(get_empty => \&_get_empty);
|
||||
$app->helper(shortener => \&_shortener);
|
||||
$app->helper(ip => \&_ip);
|
||||
$app->helper(provisioning => \&_provisioning);
|
||||
$app->helper(get_empty => \&_get_empty);
|
||||
$app->helper(shortener => \&_shortener);
|
||||
$app->helper(ip => \&_ip);
|
||||
$app->helper(default_delay => \&_default_delay);
|
||||
$app->helper(max_delay => \&_max_delay);
|
||||
$app->helper(is_selected => \&_is_selected);
|
||||
$app->helper(stop_upload => \&_stop_upload);
|
||||
$app->helper(max_delay => \&_max_delay);
|
||||
$app->helper(is_selected => \&_is_selected);
|
||||
$app->helper(stop_upload => \&_stop_upload);
|
||||
}
|
||||
|
||||
sub _pg {
|
||||
my $c = shift;
|
||||
my $c = shift;
|
||||
|
||||
state $pg = Mojo::Pg->new($c->app->pg_url($c->app->config('pgdb')));
|
||||
return $pg;
|
||||
}
|
||||
|
||||
sub _sqlite {
|
||||
my $c = shift;
|
||||
|
||||
state $sqlite = Mojo::SQLite->new('sqlite:'.$c->app->config('db_path'));
|
||||
return $sqlite;
|
||||
}
|
||||
|
||||
sub _provisioning {
|
||||
my $c = shift;
|
||||
|
||||
|
|
|
@ -23,6 +23,24 @@ sub startup {
|
|||
prefix => '/',
|
||||
theme => 'default',
|
||||
dbtype => 'sqlite',
|
||||
prefix => '/',
|
||||
provisioning => 100,
|
||||
provis_step => 5,
|
||||
length => 10,
|
||||
token_length => 32,
|
||||
secrets => ['hfudsifdsih'],
|
||||
default_delay => 0,
|
||||
max_delay => 0,
|
||||
mail => {
|
||||
how => 'sendmail'
|
||||
},
|
||||
mail_sender => 'no-reply@lufi.io',
|
||||
theme => 'default',
|
||||
upload_dir => 'files',
|
||||
session_duration => 3600,
|
||||
allow_pwd_on_files => 0,
|
||||
dbtype => 'sqlite',
|
||||
db_path => 'lufi.db',
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
hypnotoad => {
|
||||
# array of IP addresses and ports you want to listen to
|
||||
listen => ['http://127.0.0.1:8081'],
|
||||
# if you use Lufi behind a reverse proxy like Nginx, you want ro set proxy to 1
|
||||
# if you use Lufi behind a reverse proxy like Nginx, you want to set proxy to 1
|
||||
# if you use Lufi directly, let it commented
|
||||
#proxy => 1,
|
||||
|
||||
|
|
|
@ -304,7 +304,7 @@ msgstr "Si us plau contacteu amb l'administrador: %1"
|
|||
msgid "Please wait while we are getting your file. We first need to download and decrypt all parts before you can get it."
|
||||
msgstr "Si us plau, espereu mentre obtenim el fitxer. Abans que el tingueu disponible primer cal descarregar i desxifrar tots els trossos."
|
||||
|
||||
#: lib/Lufi.pm:199
|
||||
#: lib/Lufi.pm:200
|
||||
msgid "Please, check your credentials: unable to authenticate."
|
||||
msgstr ""
|
||||
|
||||
|
@ -345,7 +345,7 @@ msgstr "Compartiu fitxers amb total privacitat a %1"
|
|||
msgid "Signin"
|
||||
msgstr "Autenticació"
|
||||
|
||||
#: lib/Lufi.pm:202
|
||||
#: lib/Lufi.pm:203
|
||||
msgid "Sorry mate, you are not authorised to use that service. Contact your sysadmin if you think there's a glitch in the matrix."
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -300,7 +300,7 @@ msgstr ""
|
|||
msgid "Please wait while we are getting your file. We first need to download and decrypt all parts before you can get it."
|
||||
msgstr ""
|
||||
|
||||
#: lib/Lufi.pm:199
|
||||
#: lib/Lufi.pm:200
|
||||
msgid "Please, check your credentials: unable to authenticate."
|
||||
msgstr ""
|
||||
|
||||
|
@ -341,7 +341,7 @@ msgstr ""
|
|||
msgid "Signin"
|
||||
msgstr ""
|
||||
|
||||
#: lib/Lufi.pm:202
|
||||
#: lib/Lufi.pm:203
|
||||
msgid "Sorry mate, you are not authorised to use that service. Contact your sysadmin if you think there's a glitch in the matrix."
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -302,7 +302,7 @@ msgstr "Veuillez contacter l’administrateur : %1"
|
|||
msgid "Please wait while we are getting your file. We first need to download and decrypt all parts before you can get it."
|
||||
msgstr "Veuillez patientez pendant la récupération de votre fichier. Nous devons d’abord récupérer et déchiffrer tous les fragments avant que vous puissiez le télécharger."
|
||||
|
||||
#: lib/Lufi.pm:199
|
||||
#: lib/Lufi.pm:200
|
||||
msgid "Please, check your credentials: unable to authenticate."
|
||||
msgstr "Veuillez vérifier vos identifiants : impossible de vous authentifier."
|
||||
|
||||
|
@ -343,7 +343,7 @@ msgstr "Partagez vos fichiers en toute confidentialité sur %1"
|
|||
msgid "Signin"
|
||||
msgstr "Connexion"
|
||||
|
||||
#: lib/Lufi.pm:202
|
||||
#: lib/Lufi.pm:203
|
||||
msgid "Sorry mate, you are not authorised to use that service. Contact your sysadmin if you think there's a glitch in the matrix."
|
||||
msgstr "Désolé, vous n’êtes pas autorisé à utiliser ce service. Contactez votre administrateur si vous pensez qu’il s’agit d’une erreur."
|
||||
|
||||
|
|
|
@ -302,7 +302,7 @@ msgstr "Contattare l'amministratore : %1"
|
|||
msgid "Please wait while we are getting your file. We first need to download and decrypt all parts before you can get it."
|
||||
msgstr "Attendere mentre otteniamo il vostro file. Dobbiamo prima scaricare e decifrare tutte le parti prima che possiate averlo."
|
||||
|
||||
#: lib/Lufi.pm:199
|
||||
#: lib/Lufi.pm:200
|
||||
msgid "Please, check your credentials: unable to authenticate."
|
||||
msgstr ""
|
||||
|
||||
|
@ -347,7 +347,7 @@ msgstr "Condividi tutti i file in totale riservatezza su %1"
|
|||
msgid "Signin"
|
||||
msgstr "Autenticazione"
|
||||
|
||||
#: lib/Lufi.pm:202
|
||||
#: lib/Lufi.pm:203
|
||||
msgid "Sorry mate, you are not authorised to use that service. Contact your sysadmin if you think there's a glitch in the matrix."
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -289,7 +289,7 @@ msgstr "Neem contact op met administrator: %1"
|
|||
msgid "Please wait while we are getting your file. We first need to download and decrypt all parts before you can get it."
|
||||
msgstr "Een ogenblik geduld, we pakken je bestand er bij. We moeten alle delen downloaden en decrypten voordat je het kan downloaden."
|
||||
|
||||
#: lib/Lufi.pm:199
|
||||
#: lib/Lufi.pm:200
|
||||
msgid "Please, check your credentials: unable to authenticate."
|
||||
msgstr ""
|
||||
|
||||
|
@ -334,7 +334,7 @@ msgstr "Deel je bestanden met volledige privacy op %1"
|
|||
msgid "Signin"
|
||||
msgstr "Inloggen"
|
||||
|
||||
#: lib/Lufi.pm:202
|
||||
#: lib/Lufi.pm:203
|
||||
msgid "Sorry mate, you are not authorised to use that service. Contact your sysadmin if you think there's a glitch in the matrix."
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -302,7 +302,7 @@ msgstr "Mercés de contactar l’administrator : %1"
|
|||
msgid "Please wait while we are getting your file. We first need to download and decrypt all parts before you can get it."
|
||||
msgstr "Mercés d’esperar pendent la recuperacion de vòstre fichièr. Nos cal d’en primièr recuperar e deschifrar totes los fragaments abans que poscatz o telecargar."
|
||||
|
||||
#: lib/Lufi.pm:199
|
||||
#: lib/Lufi.pm:200
|
||||
msgid "Please, check your credentials: unable to authenticate."
|
||||
msgstr "Mercés de verificar vòstres identificants : impossible de vos autentificar."
|
||||
|
||||
|
@ -343,7 +343,7 @@ msgstr "Partejatz vòstres fichièrs en tota confidencialitat sus %1"
|
|||
msgid "Signin"
|
||||
msgstr "Connexion"
|
||||
|
||||
#: lib/Lufi.pm:202
|
||||
#: lib/Lufi.pm:203
|
||||
msgid "Sorry mate, you are not authorised to use that service. Contact your sysadmin if you think there's a glitch in the matrix."
|
||||
msgstr "O planhèm collèga, sètz pas autorizat a utilizar aqueste servici. Contactatz vòstre administrator sistèma se pensatz que i a un problèma."
|
||||
|
||||
|
|
|
@ -311,7 +311,7 @@ msgstr "Contacte o administrador: %1"
|
|||
msgid "Please wait while we are getting your file. We first need to download and decrypt all parts before you can get it."
|
||||
msgstr "Por favor aguarde durante a recuperação do seu ficheiro. Primeiro devemos recuperar e descodificar todos os fragmentos e depois poderá descarregar o ficheiro."
|
||||
|
||||
#: lib/Lufi.pm:199
|
||||
#: lib/Lufi.pm:200
|
||||
msgid "Please, check your credentials: unable to authenticate."
|
||||
msgstr ""
|
||||
|
||||
|
@ -352,7 +352,7 @@ msgstr "Partilhe os seus ficheiros com toda a privacidade em %1"
|
|||
msgid "Signin"
|
||||
msgstr "Conexão"
|
||||
|
||||
#: lib/Lufi.pm:202
|
||||
#: lib/Lufi.pm:203
|
||||
msgid "Sorry mate, you are not authorised to use that service. Contact your sysadmin if you think there's a glitch in the matrix."
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
-- 1 up
|
||||
CREATE TABLE IF NOT EXISTS files (
|
||||
short text PRIMARY KEY,
|
||||
deleted boolean default false,
|
||||
mediatype text,
|
||||
filename text,
|
||||
filesize integer,
|
||||
counter integer default 0,
|
||||
delete_at_first_view boolean,
|
||||
delete_at_day integer,
|
||||
created_at integer,
|
||||
created_by text,
|
||||
last_access_at integer,
|
||||
mod_token text,
|
||||
nbslices integer,
|
||||
complete boolean default false,
|
||||
passwd text
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS slices (
|
||||
short text NOT NULL REFERENCES files(short) ON DELETE CASCADE,
|
||||
j integer NOT NULL,
|
||||
path text unique NOT NULL,
|
||||
constraint slice_short_j UNIQUE (short, j)
|
||||
);
|
||||
-- 1 down
|
||||
DROP TABLE slices;
|
||||
DROP TABLE files;
|
|
@ -0,0 +1,28 @@
|
|||
-- 1 up
|
||||
CREATE TABLE IF NOT EXISTS files (
|
||||
short TEXT PRIMARY KEY,
|
||||
deleted INTEGER,
|
||||
mediatype TEXT,
|
||||
filename TEXT,
|
||||
filesize INTEGER,
|
||||
counter INTEGER,
|
||||
delete_at_first_view INTEGER,
|
||||
delete_at_day INTEGER,
|
||||
created_at INTEGER,
|
||||
created_by TEXT,
|
||||
last_access_at INTEGER,
|
||||
mod_token TEXT,
|
||||
nbslices INTEGER,
|
||||
complete INTEGER
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS slices (
|
||||
short TEXT,
|
||||
j INTEGER,
|
||||
path TEXT,
|
||||
FOREIGN KEY (short) REFERENCES files(short)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS slices_idx ON slices(short);
|
||||
-- 1 down
|
||||
DROP INDEX slices_idx ON slices(short);
|
||||
DROP TABLE slices;
|
||||
DROP TABLE files;
|
|
@ -1,28 +0,0 @@
|
|||
-- 1 up
|
||||
CREATE TABLE IF NOT EXISTS files (
|
||||
short text PRIMARY KEY,
|
||||
deleted boolean default false,
|
||||
mediatype text,
|
||||
filename text,
|
||||
filesize integer,
|
||||
counter integer default 0,
|
||||
delete_at_first_view boolean,
|
||||
delete_at_day integer,
|
||||
created_at integer,
|
||||
created_by text,
|
||||
last_access_at integer,
|
||||
mod_token text,
|
||||
nbslices integer,
|
||||
complete boolean default false,
|
||||
passwd text
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS slices (
|
||||
short text NOT NULL REFERENCES files(short) ON DELETE CASCADE,
|
||||
j integer NOT NULL,
|
||||
path text unique NOT NULL,
|
||||
constraint slice_short_j UNIQUE (short, j)
|
||||
);
|
||||
-- 1 down
|
||||
DROP TABLE slices;
|
||||
DROP TABLE files;
|
Loading…
Reference in New Issue