diff options
Diffstat (limited to 'bucky2/bin/flush-files')
| -rw-r--r-- | bucky2/bin/flush-files | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/bucky2/bin/flush-files b/bucky2/bin/flush-files new file mode 100644 index 0000000..31648db --- /dev/null +++ b/bucky2/bin/flush-files @@ -0,0 +1,44 @@ +#!/usr/bin/perl +use strict; +use lib "../lib"; +use Bucky; + +my $bucky = new Bucky; +my $thread_list = $bucky->db->select("thread"); +my $thread_map = {}; +foreach my $t (@$thread_list) { + $thread_map->{ $t->{'id'} } = 1; +} + +my $base = "/var/www/vhosts/carbonpictures.com/bucky/data/"; +opendir(DIR, $base) or die $!; +my @dirs = readdir(DIR); +closedir(DIR); + +# print scalar @dirs; + +foreach my $thread_id (@dirs) { + my $dir = $base . $thread_id; + + next unless (-d $dir && $thread_id !~ /^\./); + next if (exists($thread_map->{$thread_id})); + + opendir (THREAD, $dir); + my @local_files = readdir(THREAD); + closedir (THREAD); + + my $size = `du -sh $dir`; + print $size; + print join("\n", sort(@local_files)); + print "\n"; + my $line = readline(STDIN); + if (substr($line, 0, 1) eq 'y') { + print "\n"; + print ">>> delete " . $dir . "\n"; + print "\n"; + system('rm', '-rf', $dir); + } + print "\n\n"; +} + + |
