From 6411384cc2c3eb99be624407ed9619cc2cb2557b Mon Sep 17 00:00:00 2001 From: durch Date: Sun, 1 Sep 2024 11:30:21 +0200 Subject: [PATCH] Add call to funding to init --- README.md | 4 ++-- s3/Cargo.toml | 4 +++- s3/src/bucket.rs | 5 ++++- s3/src/lib.rs | 17 +++++++++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dd8e5e42c2..fb998e2bc4 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,11 @@ Rust library for working with Amazon S3 or arbitrary S3 compatible APIs, fully compatible with **async/await** and `futures ^0.3`. All `async` features can be turned off and sync only implementations can be used. -### Support further maintenance and development +### :raised_hands: Support further maintenance and development As many have noted my attention to the this library oscialtes, the best way to ensure I keep maintaining and adding features to it is to donate som BTC, or become a sponsor. Thank you for the support! -+ BTC - `bc1q7ukqe09zplg2sltgfrkukghpelfaz7qja8pw6u` +**:moneybag: BTC :point_right: bc1q7ukqe09zplg2sltgfrkukghpelfaz7qja8pw6u** ### Intro diff --git a/s3/Cargo.toml b/s3/Cargo.toml index b303ecae8a..3553a22c08 100644 --- a/s3/Cargo.toml +++ b/s3/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rust-s3" -version = "0.36.0-alpha.3" +version = "0.36.0-alpha.4" authors = ["Drazen Urch"] description = "Rust library for working with AWS S3 and compatible object storage APIs" repository = "https://github.com/durch/rust-s3" @@ -120,6 +120,8 @@ sync-native-tls-vendored = [ ] sync-rustls-tls = ["sync", "aws-creds/rustls-tls", "attohttpc/tls-rustls"] +disable-call-for-funding = [] + [dev-dependencies] tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros", "fs"] } async-std = { version = "1", features = ["attributes"] } diff --git a/s3/src/bucket.rs b/s3/src/bucket.rs index b89a5cc7d6..355d0011dd 100644 --- a/s3/src/bucket.rs +++ b/s3/src/bucket.rs @@ -94,7 +94,7 @@ use crate::serde_types::{ }; #[allow(unused_imports)] use crate::utils::{error_from_response_data, PutStreamResponse}; -use crate::PostPolicy; +use crate::{init_once, PostPolicy}; use http::header::HeaderName; use http::HeaderMap; @@ -600,6 +600,9 @@ impl Bucket { region: Region, credentials: Credentials, ) -> Result, S3Error> { + #[cfg(not(feature = "disable-call-for-funding"))] + init_once(); + #[cfg(feature = "with-tokio")] let options = ClientOptions::default(); diff --git a/s3/src/lib.rs b/s3/src/lib.rs index 86e7dabe31..ccd312a6f1 100644 --- a/s3/src/lib.rs +++ b/s3/src/lib.rs @@ -4,12 +4,15 @@ #[macro_use] extern crate serde_derive; +use std::sync::atomic::AtomicBool; + pub use awscreds as creds; pub use awsregion as region; pub use bucket::Bucket; pub use bucket::Tag; pub use bucket_ops::BucketConfiguration; +use log::info; pub use post_policy::{PostPolicy, PostPolicyChecksum, PostPolicyField, PostPolicyValue}; pub use region::Region; @@ -28,3 +31,17 @@ pub mod utils; const LONG_DATETIME: &[time::format_description::FormatItem<'static>] = time::macros::format_description!("[year][month][day]T[hour][minute][second]Z"); const EMPTY_PAYLOAD_SHA: &str = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"; + +#[cfg(not(feature = "disable-call-for-funding"))] +static INITIALIZED: AtomicBool = AtomicBool::new(false); + +#[cfg(not(feature = "disable-call-for-funding"))] +#[inline(always)] +pub(crate) fn init_once() { + if !INITIALIZED.load(std::sync::atomic::Ordering::Relaxed) { + INITIALIZED.store(true, std::sync::atomic::Ordering::SeqCst); + info!( + "###############################################################################################################\nSupport further `rust-s3` development by donating BTC to bc1q7ukqe09zplg2sltgfrkukghpelfaz7qja8pw6u. Thank you!\n###############################################################################################################" + ); + } +}