- Timestamp:
- 03/24/06 00:15:31 (19 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Changes
r12 r13 3 3 0.03 4 4 - added "exclude_path" option to filesystem backend 5 - added "sync_db" method to the DB backend 5 6 6 7 0.02 1 Feb 2006 -
trunk/Makefile.PL
r3 r13 12 12 EXE_FILES => [qw( 13 13 bin/mp3find 14 bin/mp3db 14 15 )], 15 16 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 -
trunk/lib/MP3/Find.pm
r10 r13 9 9 use Carp; 10 10 11 $VERSION = '0.0 2';11 $VERSION = '0.03'; 12 12 13 13 @EXPORT = qw(find_mp3s); -
trunk/lib/MP3/Find/DB.pm
r12 r13 147 147 } 148 148 149 sub sync_db { 150 my $self = shift; 151 my $db_file = shift or croak "Need the name of the databse to sync"; 152 153 my $dbh = DBI->connect("dbi:SQLite:dbname=$db_file", '', '', {RaiseError => 1}); 154 my $select_sth = $dbh->prepare('SELECT FILENAME FROM mp3'); 155 my $delete_sth = $dbh->prepare('DELETE FROM mp3 WHERE FILENAME = ?'); 156 157 # the number of records removed 158 my $count = 0; 159 160 $select_sth->execute; 161 while (my ($filename) = $select_sth->fetchrow_array) { 162 unless (-e $filename) { 163 $delete_sth->execute($filename); 164 print STDERR "D $filename\n"; 165 $count++; 166 } 167 } 168 169 return $count; 170 } 171 149 172 sub destroy_db { 150 173 my $self = shift; … … 259 282 sinc ethe last time C<update_db> was run. 260 283 284 =head2 sync_db 285 286 my $count = $finder->sync_db($db_filename); 287 288 Removes entries from the database that refer to files that no longer 289 exist in the filesystem. Returns the count of how many records were 290 removed. 291 261 292 =head2 destroy_db 262 293 … … 270 301 271 302 Allow the passing of a DSN or an already created C<$dbh> instead 272 of a SQLite database filename. 303 of a SQLite database filename; or write driver classes to handle 304 database dependent tasks (create_db/destroy_db). 273 305 274 306 =head1 SEE ALSO
Note: See TracChangeset
for help on using the changeset viewer.