X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/8b7389b426a7a9833b0bd40dca285b746d81b5a1..5397cca7350747805cf47df05e63f18ac6746bf2:/IkiWiki/Plugin/amazon_s3.pm

diff --git a/IkiWiki/Plugin/amazon_s3.pm b/IkiWiki/Plugin/amazon_s3.pm
index 0482178ea..a9da6bf12 100644
--- a/IkiWiki/Plugin/amazon_s3.pm
+++ b/IkiWiki/Plugin/amazon_s3.pm
@@ -63,7 +63,7 @@ sub getsetup () {
 		amazon_s3_bucket => {
 			type => "string",
 			example => "mywiki",
-			description => "globally unique name of bucket to store wiki into",
+			description => "globally unique name of bucket to store wiki in",
 			safe => 1,
 			rebuild => 1,
 		},
@@ -133,7 +133,11 @@ sub getbucket {
 	}
 
 	if (! $bucket) {
-		error(gettext("Failed to create bucket inside S3: ").
+		# Try to use existing bucket.
+		$bucket=$s3->bucket($config{amazon_s3_bucket});
+	}
+	if (! $bucket) {
+		error(gettext("Failed to create S3 bucket: ").
 			$s3->err.": ".$s3->errstr."\n");
 	}
 
@@ -178,7 +182,7 @@ sub writefile ($$$;$$) {
 
 	# First, write the file to disk.
 	my $ret=$IkiWiki::Plugin::amazon_s3::subs{'IkiWiki::writefile'}->($file, $destdir, $content, $binary, $writer);
-		
+
 	my @keys=IkiWiki::Plugin::amazon_s3::file2keys("$destdir/$file");
 
 	# Store the data in S3.
@@ -218,7 +222,7 @@ sub writefile ($$$;$$) {
 				}
 			}
 			if (! $res) {
-				error(gettext("Failed to save file into S3: ").
+				error(gettext("Failed to save file to S3: ").
 					$bucket->err.": ".$bucket->errstr."\n");
 			}
 		}
@@ -228,8 +232,9 @@ sub writefile ($$$;$$) {
 }
 
 # This is a wrapper around the real prune.
-sub prune ($) {
+sub prune ($;$) {
 	my $file=shift;
+	my $up_to=shift;
 
 	my @keys=IkiWiki::Plugin::amazon_s3::file2keys($file);
 
@@ -240,13 +245,13 @@ sub prune ($) {
 		foreach my $key (@keys) {
 			my $res=$bucket->delete_key($key);
 			if (! $res) {
-				error(gettext("Failed to delete file inside S3: ").
+				error(gettext("Failed to delete file from S3: ").
 					$bucket->err.": ".$bucket->errstr."\n");
 			}
 		}
 	}
 
-	return $IkiWiki::Plugin::amazon_s3::subs{'IkiWiki::prune'}->($file);
+	return $IkiWiki::Plugin::amazon_s3::subs{'IkiWiki::prune'}->($file, $up_to);
 }
 
 1