#!/usr/bin/perl use localbucky; use lib "/var/www/vhosts/carbonpictures.com/bucky/lib"; use Bucky1; $dbh = DBI->connect ("DBI:mysql:$BUCKY_DB:localhost;mysql_read_default_file=$BUCKY_DB_CNF"); #our $dbh = DBI->connect ($dsn); #our $DEBUG = 1; my $threads = get_threads(); my ($zips, $zip_size) = find_all_zips($threads); print STDERR scalar(@$zips)." in ".hushsize($zip_size)."\n"; foreach my $f (@$zips) { delete_file($f); } $dbh->disconnect(); sub find_all_zips { my ($threads) = @_; my @zips; my $zip_size = 0; foreach my $t (@$threads) { my $files = get_files($t->{id}); my $zip_file = generate_zip_filename($t); foreach my $f (@$files) { next unless $f->{filename} eq $zip_file; push @zips, $f; $zip_size += $f->{size}; } } return \@zips, $zip_size; } sub delete_file { my ($f) = @_; my $file_path = join "/", $data_path, $f->{thread}, $f->{filename}; if (! -e $file_path) { print STDERR "DNE: $file_path ...\n"; return; } delete_file_record($f->{id}); system($RM_PATH, "-f", $file_path); update_thread_size($f->{thread}); print STDERR qq(deleted $file_path\n); }