diff options
| author | Jules Laplace <carbon@melanarchy.org> | 2013-08-02 17:14:26 -0500 |
|---|---|---|
| committer | Jules Laplace <carbon@melanarchy.org> | 2013-08-02 17:14:26 -0500 |
| commit | 79670053c7247d3a49b607960efd284e93f057e5 (patch) | |
| tree | 9617f6eefa38b2686ae409bf75cc27a340444eda /bin/flushzips.pl | |
| parent | c53827d5d044ae5ca7ebb27acb404b7a8988918e (diff) | |
install.pl
Diffstat (limited to 'bin/flushzips.pl')
| -rwxr-xr-x | bin/flushzips.pl | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/bin/flushzips.pl b/bin/flushzips.pl new file mode 100755 index 0000000..392e782 --- /dev/null +++ b/bin/flushzips.pl @@ -0,0 +1,54 @@ +#!/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); + } + |
