mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-20 13:50:12 +01:00
if the AWS S3 bucket does not exist, create it
This makes the AWS S3 setup dead simple: just put in a awsbucket name of your choosing, set the AWS credentials, and it'll do the rest, whether the bucket exists already or not. S3 buckets are trivial to delete too, in case of error: `s3cmd rb s3://mybadbucketname`.
This commit is contained in:
parent
f0def08add
commit
98033f3270
@ -38,7 +38,7 @@ def update_awsbucket(repo_section):
|
||||
|
||||
import libcloud.security
|
||||
libcloud.security.VERIFY_SSL_CERT = True
|
||||
from libcloud.storage.types import Provider
|
||||
from libcloud.storage.types import Provider, ContainerDoesNotExistError
|
||||
from libcloud.storage.providers import get_driver
|
||||
|
||||
if 'awsaccesskeyid' not in config or 'awssecretkey' not in config:
|
||||
@ -48,7 +48,11 @@ def update_awsbucket(repo_section):
|
||||
|
||||
cls = get_driver(Provider.S3)
|
||||
driver = cls(config['awsaccesskeyid'], config['awssecretkey'])
|
||||
try:
|
||||
container = driver.get_container(container_name=awsbucket)
|
||||
except ContainerDoesNotExistError:
|
||||
container = driver.create_container(container_name=awsbucket)
|
||||
logging.info('Created new container "' + container.name + '"')
|
||||
|
||||
upload_dir = 'fdroid/' + repo_section
|
||||
if options.verbose:
|
||||
|
Loading…
Reference in New Issue
Block a user