X-Git-Url: https://git.sesse.net/?p=pr0n;a=blobdiff_plain;f=perl%2FSesse%2Fpr0n%2FCommon.pm;h=559d6339f38b206498902f801ffa721d777c6593;hp=72f3b75b15d80fc1442a32e10efe2c216a404a20;hb=290a2bdcb92997fd2537603dee5c67350b2bb7b1;hpb=d0c5bf570026f38da0b86586ea46f39a747ceaae diff --git a/perl/Sesse/pr0n/Common.pm b/perl/Sesse/pr0n/Common.pm index 72f3b75..559d633 100644 --- a/perl/Sesse/pr0n/Common.pm +++ b/perl/Sesse/pr0n/Common.pm @@ -39,7 +39,7 @@ BEGIN { require Sesse::pr0n::Config_local; }; - $VERSION = "v2.71"; + $VERSION = "v2.72"; @ISA = qw(Exporter); @EXPORT = qw(&error &dberror); %EXPORT_TAGS = qw(); @@ -211,7 +211,7 @@ sub get_base { my $r = shift; return $r->dir_config('ImageBase'); } - + sub get_disk_location { my ($r, $id) = @_; my $dir = POSIX::floor($id / 256); @@ -231,6 +231,23 @@ sub get_cache_location { } } +sub ensure_disk_location_exists { + my ($r, $id) = @_; + my $dir = POSIX::floor($id / 256); + + my $img_dir = get_base($r) . "/images/$dir/"; + if (! -d $img_dir) { + $r->log->info("Need to create new image directory $img_dir"); + mkdir($img_dir) or die "Couldn't create new image directory $img_dir"; + } + + my $cache_dir = get_base($r) . "/cache/$dir/"; + if (! -d $cache_dir) { + $r->log->info("Need to create new cache directory $cache_dir"); + mkdir($cache_dir) or die "Couldn't create new image directory $cache_dir"; + } +} + sub get_mipmap_location { my ($r, $id, $width, $height) = @_; my $dir = POSIX::floor($id / 256); @@ -1100,8 +1117,6 @@ sub purge_cache { } $regex .= "(\\?.*)?\$"; $r->headers_out->{'X-Pr0n-Purge'} = $regex; - - $r->log->info($r->headers_out->{'X-Pr0n-Purge'}); } # Find a list of all cache URLs for a given image, given what we have on disk.