diff options
author | Guilhem Moulin <guilhem.moulin@ens-lyon.org> | 2012-02-17 22:57:13 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem.moulin@ens-lyon.org> | 2012-02-17 22:57:13 +0100 |
commit | 0129cd78f1516df6d2af2a2eb81b58a039bfb1b5 (patch) | |
tree | d6c538db4ddd8fdea0fcbed9efa2fcc18ea4e2ae | |
parent | f8a039e6e65acc809b353f90d76c023e277de84e (diff) |
prefix
-rwxr-xr-x | videodb-check.pl | 11 | ||||
-rw-r--r-- | videodb.rc | 4 | ||||
-rwxr-xr-x | videomv.pl | 9 | ||||
-rwxr-xr-x | videorm.pl | 9 |
4 files changed, 18 insertions, 15 deletions
diff --git a/videodb-check.pl b/videodb-check.pl index 11c5de2..14d58ed 100755 --- a/videodb-check.pl +++ b/videodb-check.pl @@ -24,7 +24,8 @@ my %config = do $confile; die "Error in `" .$confile. "'\n" if $@ || not %config; map { exists $config{$_} || die "Error: Missing `${_}'.\n" } - qw /videodir driver database hostname user port password videodata/; + qw /videodir driver database hostname user port password/; +$config{prefix} = "" unless exists $config{prefix}; my $symlinks = catdir($config{videodir},'MOVIES'); # Symlinks folder die "Error: No such directory: `" .$symlinks. "'.\n" unless -d $symlinks; @@ -105,7 +106,7 @@ e.g., user => 'username', port => 3306, password => '******', - videodata => "videodb_videodata", + prefix => "videodb_", =head1 EXIT STATUS @@ -149,7 +150,7 @@ $dbh->do( "set names utf8" ) or die; # valid target my $r = 0; # Exit status -my $res = $dbh->selectall_arrayref ( "SELECT filename,director FROM $config{videodata}" ) +my $res = $dbh->selectall_arrayref ( "SELECT filename,director FROM $config{prefix}videodata" ) or die "Can't select: " .$dbh->errstr. "\n"; @@ -214,7 +215,7 @@ closedir(DIR) or die "Can't close: $!\n"; undef @files; -my $sth = $dbh->prepare ( "SELECT id FROM $config{videodata} WHERE filename = ?" ) +my $sth = $dbh->prepare ( "SELECT id FROM $config{prefix}videodata WHERE filename = ?" ) or die "Error: " .$dbh->errstr; foreach (@filelist) { $sth->execute ($_) or die "Can't select: " .$dbh->errstr. "\n"; @@ -255,7 +256,7 @@ sub report { sub check { my $bad = $dbh->selectall_arrayref( "SELECT filename - FROM $config{videodata} + FROM $config{prefix}videodata WHERE " .$_[1] ) or die "Can't select: " .$dbh->errstr. "\n"; &report ("The following files have " .$_[0], [map {$_->[0]} @$bad]); @@ -14,7 +14,7 @@ dbi_misc => { mysql_ssl => 1 , mysql_ssl_ca_file => "/etc/ssl/certs/cacert.org.pem" }, password => '******', -videodata => "videodb_videodata", +prefix => 'videodb_', +userid => 1, imdb => 'akas.imdb.com', url => 'https://videodb.example.org', -userid => 1 @@ -29,7 +29,8 @@ my %config = do $confile; die "Error in `" .$confile. "'\n" if $@ || not %config; map { exists $config{$_} || die "Error: Missing `${_}'.\n" } - qw /videodir driver database hostname user port password videodata/; + qw /videodir driver database hostname user port password/; +$config{prefix} = "" unless exists $config{prefix}; my $symlinks = catdir($config{videodir},'MOVIES'); # Symlinks folder die "Error: No such directory: `" .$symlinks. "'.\n" unless -d $symlinks; @@ -310,7 +311,7 @@ e.g., user => 'username', port => 3306, password => '******', - videodata => "videodb_videodata", + prefix => "videodb_", =head1 EXIT STATUS @@ -391,7 +392,7 @@ unless (defined $ignoredb_flag) { # Lookup for the file in the videodb database $RES = - $dbh->selectall_hashref ( "SELECT id,director,title FROM $config{videodata} + $dbh->selectall_hashref ( "SELECT id,director,title FROM $config{prefix}videodata WHERE filename = ?", 'id', undef, $old_filename ) @@ -574,7 +575,7 @@ unless ($r || defined ($ignoredb_flag) || $old_filename eq $new_filename) { &revert(@actions); } else { - my $rv = $dbh->do ( "UPDATE $config{videodata} SET filename = ? WHERE id = ?", + my $rv = $dbh->do ( "UPDATE $config{prefix}videodata SET filename = ? WHERE id = ?", undef, $new_filename, $id ); &ack (\$r, $rv); @@ -29,7 +29,8 @@ my %config = do $confile; die "Error in `" .$confile. "'\n" if $@ || not %config; map { exists $config{$_} || die "Error: Missing `${_}'.\n" } - qw /videodir driver database hostname user port password videodata/; + qw /videodir driver database hostname user port password/; +$config{prefix} = "" unless exists $config{prefix}; my $symlinks = catdir($config{videodir},'MOVIES'); # Symlinks folder die "Error: No such directory: `" .$symlinks. "'.\n" unless -d $symlinks; @@ -112,7 +113,7 @@ e.g., user => 'username', port => 3306, password => '******', - videodata => "videodb_videodata", + prefix => "videodb_", =head1 EXIT STATUS @@ -172,7 +173,7 @@ $dbh->do( "set names utf8" ) or die; # Lookup for the file in the videodb database -my $res = $dbh->selectall_arrayref ( "SELECT id FROM $config{videodata} WHERE filename = ?", +my $res = $dbh->selectall_arrayref ( "SELECT id FROM $config{prefix}videodata WHERE filename = ?", undef, $file ) or die "Can't select: " .$dbh->errstr. "\n"; @@ -184,7 +185,7 @@ die "Error: Your collection is not sane! (and `--force' is not set).\n" my $r = 0; &ack ( "Updating database... ", - $dbh->do ( "DELETE FROM $config{videodata} WHERE filename = ?", undef, $file ) > 0); + $dbh->do ( "DELETE FROM $config{prefix}videodata WHERE filename = ?", undef, $file ) > 0); &ack ( "Deleting symlink... ", -l $file_s && unlink $file_s ); |