Skip to content
Snippets Groups Projects
Verified Commit e104c656 authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Indexer zaznamu

parent 41b22c25
No related branches found
No related tags found
No related merge requests found
Pipeline #2123 passed
...@@ -2,7 +2,7 @@ image: docker:19.03.12 ...@@ -2,7 +2,7 @@ image: docker:19.03.12
variables: variables:
DOCKER_TLS_CERTDIR: "/certs" DOCKER_TLS_CERTDIR: "/certs"
IMAGE_VER: 1.6.0 IMAGE_VER: 1.7.0
services: services:
- docker:19.03.12-dind - docker:19.03.12-dind
......
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin qw($Bin);
use lib "$Bin/../lib";
use File::Copy;
use constant YAMDI => '/usr/bin/yamdi';
#use PiTube::Schema;
use Mojo::Pg;
my $pg = Mojo::Pg->new
->dsn($ENV{DB_DSN})
->username($ENV{DB_USERNAME})
->password($ENV{DB_PASSWORD})
;
my $records = $pg->db->query(qq[
select id,path from records
where not is_indexed
and path <> ''
]);
RECORD:
while (my $record = $records->hash) {
next RECORD if ! -f $record->{path};
print "Indexing $record->{path}\n";
system(YAMDI, '-i', $record->{path}, '-o', $record->{path} . '.idx' );
if ($?) {
print "ERROR $!\n";
}
else {
move($record->{path} . '.idx', $record->{path});
$pg->db->update(
'records',
{is_indexed => 't'},
{id => $record->{id}},
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment