Skip to content
This repository has been archived by the owner on Dec 20, 2020. It is now read-only.

Commit

Permalink
Add debugging to get_md5 subroutine.
Browse files Browse the repository at this point in the history
Remove dbh quoting in bulk_add, since using placeholders in the statement handle takes care of that anyway.

Fix a bug in getting the MD5 for the bulk-added file.
  • Loading branch information
minter committed Jul 29, 2005
1 parent a2a55e1 commit cfb25f6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
@@ -1,3 +1,9 @@
Fri Jul 29 2005 H. Wade Minter (minter@lunenburg.org)
* Add debugging to get_md5 subroutine.
* Remove dbh quoting in bulk_add, since using placeholders in the
statement handle takes care of that anyway.
* Fix a bug in getting the MD5 for the bulk-added file.

Mon Jul 25 2005 H. Wade Minter (minter@lunenburg.org)
* Bump version to 2.0.9c (final beta?)

Expand Down
24 changes: 10 additions & 14 deletions mrvoice.pl
Expand Up @@ -1754,26 +1754,18 @@ sub bulk_add
# Valid title, all we need
my $time = get_songlength($file);
print "Got time $time\n" if $debug;
my $md5 = get_md5( catfile( $config{filepath}, $file ) );
my $db_title = $dbh->quote($title);
my $db_artist;
if ( ($artist) && ( $artist !~ /^\s*$/ ) )
{
$db_artist = $dbh->quote($artist);
}
else
{
$db_artist = "NULL";
}
my $md5 = get_md5($file);
$artist = "NULL" unless $artist;
my $db_filename = move_file( $file, $title, $artist );
print "Moved file to $db_filename\n" if $debug;
my $moved_md5 =
get_md5( catfile( $config{filepath}, $db_filename ) );
$sth->execute( $db_title, $db_artist, $db_cat, $db_filename, $time,
$sth->execute( $title, $artist, $db_cat, $db_filename, $time,
$bulkadd_publisher, $moved_md5 )
or die "can't execute the query: $DBI::errstr\n";
print "Executed sth\n" if $debug;
$sth->finish;

if ( $^O eq "MSWin32" )
{
push( @accepted, basename( Win32::GetLongPathName($file) ) );
Expand Down Expand Up @@ -3989,12 +3981,16 @@ sub play_mp3

sub get_md5
{
print "Getting MD5sum\n" if $debug;
my $filename = shift;
print "Checking MD5 for file $filename\n" if $debug;
local $/ = undef;
open( my $fh, "<", $filename );
open( my $fh, "<", $filename ) or die "Couldn't open $filename";
binmode($fh);
my $bindata = <$fh>;
return md5_hex($bindata);
my $md5 = md5_hex($bindata);
print "Returning MD5 $md5\n" if $debug;
return $md5;
}

sub get_songlength
Expand Down

0 comments on commit cfb25f6

Please sign in to comment.