]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/amazon_s3.pm
(no commit message)
[git.ikiwiki.info.git] / IkiWiki / Plugin / amazon_s3.pm
index 0482178eab3e4e5b61f2a2217722f53e79c70d61..a9da6bf12b69dc62f2ee05f22aaaef2c88fe7dde 100644 (file)
@@ -63,7 +63,7 @@ sub getsetup () {
                amazon_s3_bucket => {
                        type => "string",
                        example => "mywiki",
                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,
                },
                        safe => 1,
                        rebuild => 1,
                },
@@ -133,7 +133,11 @@ sub getbucket {
        }
 
        if (! $bucket) {
        }
 
        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");
        }
 
                        $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);
 
        # 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.
        my @keys=IkiWiki::Plugin::amazon_s3::file2keys("$destdir/$file");
 
        # Store the data in S3.
@@ -218,7 +222,7 @@ sub writefile ($$$;$$) {
                                }
                        }
                        if (! $res) {
                                }
                        }
                        if (! $res) {
-                               error(gettext("Failed to save file into S3: ").
+                               error(gettext("Failed to save file to S3: ").
                                        $bucket->err.": ".$bucket->errstr."\n");
                        }
                }
                                        $bucket->err.": ".$bucket->errstr."\n");
                        }
                }
@@ -228,8 +232,9 @@ sub writefile ($$$;$$) {
 }
 
 # This is a wrapper around the real prune.
 }
 
 # This is a wrapper around the real prune.
-sub prune ($) {
+sub prune ($;$) {
        my $file=shift;
        my $file=shift;
+       my $up_to=shift;
 
        my @keys=IkiWiki::Plugin::amazon_s3::file2keys($file);
 
 
        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) {
                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");
                        }
                }
        }
 
                                        $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
 }
 
 1