Skip to content

Commit

Permalink
Only delete konserve files on store deletion.
Browse files Browse the repository at this point in the history
  • Loading branch information
whilo committed Mar 28, 2023
1 parent 7ccdbf3 commit b0a10ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ For asynchronous execution take a look at the [konserve example](https://github.

Note that you do not need full S3 rights if you manage the bucket outside, i.e.
create it before and delete it after usage form a privileged account. Connection
will otherwise create a bucket and it can be recursively deleted by
`delete-store.` You can activate [Amazon X-Ray](https://aws.amazon.com/xray/) by
setting `:x-ray?` to `true` in the S3 spec.
will otherwise create a bucket and all files created by konserve (with suffix
".ksv", ".ksv.new" or ".ksv.backup") will be deleted by `delete-store`, but the
bucket needs to be separately deleted by `delete-bucket`. You can activate
[Amazon X-Ray](https://aws.amazon.com/xray/) by setting `:x-ray?` to `true` in
the S3 spec.

## Authentication

Expand Down
9 changes: 6 additions & 3 deletions src/konserve_s3/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,13 @@
(-delete-store [_ env]
(async+sync (:sync? env) *default-sync-translation*
(go-try- (when (bucket-exists? client bucket)
(info "AWS requires deletion of all keys first. This will be done sequentially now, but it will be faster to delete the bucket from the console.")
(doseq [key (list-objects client bucket)]
(info "This will delete all konserve files, but won't delete the bucket. You can use konserve-s3.core/delete-bucket if you intend to delete the bucket as well.")
(doseq [key (filter (fn [^String key]
(or (.endsWith key ".ksv")
(.endsWith key ".ksv.new")
(.endsWith key ".ksv.backup")))
(list-objects client bucket))]
(delete client bucket key))
(delete-bucket client bucket)
(.close client)))))
(-keys [_ env]
(async+sync (:sync? env) *default-sync-translation*
Expand Down

0 comments on commit b0a10ff

Please sign in to comment.