summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-05-07 23:51:25 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-05-07 23:51:25 -0400
commit0850cde5a6a77898e6ae88173a34bc641414deb9 (patch)
tree4f24d6d61aee3f0539b2ab6f6d39b6d6093aacd6 /IkiWiki/Plugin
parentbe89d6749eca74a3cfe80a86fa8416e8c8a2367b (diff)
implemented pruning, s3 support now complete-ish
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/amazon_s3.pm21
1 files changed, 18 insertions, 3 deletions
diff --git a/IkiWiki/Plugin/amazon_s3.pm b/IkiWiki/Plugin/amazon_s3.pm
index b5629eb4a..0613d4357 100644
--- a/IkiWiki/Plugin/amazon_s3.pm
+++ b/IkiWiki/Plugin/amazon_s3.pm
@@ -152,10 +152,25 @@ sub writefile ($$$;$$) { #{{{
sub prune ($) { #{{{
my $file=shift;
- my $bucket=IkiWiki::Plugin::amazon_s3::getbucket();
- print STDERR "wrapped prune\n";
+ # If a file in the destdir is being pruned, need to delete it out
+ # of S3 as well.
+ if ($file =~ /^\Q$config{destdir}\/\E(.*)/) {
+ my $key=$config{amazon_s3_prefix}.$1;
+ print STDERR "wrapped prune ($key)\n";
+ my $bucket=IkiWiki::Plugin::amazon_s3::getbucket();
+ my $res=$bucket->delete_key($key);
+ if ($res && $key=~/(^|\/)index.$config{htmlext}$/) {
+ # index.html special case: Delete other file too
+ $key=~s/index.$config{htmlext}$//;
+ $res=$bucket->delete_key($key);
+ }
+ if (! $res) {
+ error(gettext("Failed to delete file from S3: ").
+ $bucket->err.": ".$bucket->errstr."\n");
+ }
+ }
- return $IkiWiki::Plugin::amazon_s3::subs{'IkiWiki::writefile'}->($file);
+ return $IkiWiki::Plugin::amazon_s3::subs{'IkiWiki::prune'}->($file);
} #}}}
1