From 872c5487c01bc88480edf648a122231cf15b5a82 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 10 Dec 2017 21:41:45 +0100 Subject: move bucky off melanarchy --- bucky2/bin/flush-files | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 bucky2/bin/flush-files (limited to 'bucky2') 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"; +} + + -- cgit v1.2.3-70-g09d2