switch back to tokio, this works onlyfor non-dirs
This commit is contained in:
1 parent
68aeded077
commit
e9ad9bbfe0
4 files changed
+207
-570
No files matched your search
Generated
+170
-553
File diff suppressed because it is too large.
Load diff
+9
-4
@@ -32,7 +32,6 @@ path = "src/w2l_inference_job.rs"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.40"
|
||||
async-std = { version = "1.6", features = [ "attributes" ] }
|
||||
base64 = "0.13.0"
|
||||
chrono = { version = "0.4.19", features = ["serde"] }
|
||||
derive_more = "0.99.14"
|
||||
@@ -47,17 +46,23 @@ rand = "0.8.3"
|
||||
regex = "1.5.4"
|
||||
time = "0.2.26"
|
||||
|
||||
# Runtime
|
||||
#async-std = { version = "1.6", features = [ "attributes" ] }
|
||||
tokio = { version = "1.6.0", features = ["macros"] }
|
||||
|
||||
# Database
|
||||
# "offline" supports typesafe builds without a live database
|
||||
# "rustls" doesn't appear to work with IP addresses, per:
|
||||
# https://github.com/launchbadge/sqlx/issues/1095#issuecomment-798050828
|
||||
sqlx = { version = "0.5", features = [ "mysql", "runtime-async-std-native-tls", "offline", "chrono" ] }
|
||||
#sqlx = { version = "0.5", features = [ "mysql", "runtime-async-std-native-tls", "offline", "chrono" ] }
|
||||
sqlx = { version = "0.5", features = [ "mysql", "runtime-actix-native-tls", "offline", "chrono" ] }
|
||||
|
||||
# Files
|
||||
data-encoding = "2.3.2"
|
||||
ring = "0.17.0-alpha.10"
|
||||
#rust-s3 = "0.27.0-rc4"
|
||||
rust-s3 = { version = "=0.27.0-beta5", features = ["with-async-std"], default-features = false }
|
||||
rust-s3 = "0.27.0-rc4"
|
||||
#rust-s3 = { version = "0.27.0-rc4", features = ["with-async-std"], default-features = false }
|
||||
#rust-s3 = { version = "0.26" }
|
||||
|
||||
tempdir = "0.3.7"
|
||||
|
||||
|
||||
+16
-6
@@ -48,7 +48,7 @@ struct Downloader {
|
||||
pub download_script: String,
|
||||
}
|
||||
|
||||
#[async_std::main]
|
||||
#[tokio::main]
|
||||
async fn main() -> AnyhowResult<()> {
|
||||
easyenv::init_all_with_default_logging(Some(DEFAULT_RUST_LOG));
|
||||
|
||||
@@ -255,16 +255,26 @@ async fn process_job(downloader: &Downloader, job: &TtsUploadJobRecord) -> Anyho
|
||||
|
||||
info!("File hash: {}", private_bucket_hash);
|
||||
|
||||
let object_name = format!(
|
||||
"user_uploaded_tts_models/{}/{}/{}/{}.bin",
|
||||
/*let object_name = format!(
|
||||
"/user_uploaded_tts_models/{}/{}/{}/{}.bin",
|
||||
&private_bucket_hash[0..1],
|
||||
&private_bucket_hash[1..2],
|
||||
&private_bucket_hash[2..3],
|
||||
&private_bucket_hash,
|
||||
);
|
||||
);*/
|
||||
|
||||
//"/dev-vocodes-private-uploads/user_uploaded_tts_models/foobarbaz.bin",
|
||||
//"/dev-vocodes-private-uploads/foobarbaz.bin",
|
||||
//"/user_uploaded_tts_models/foobarbaz",
|
||||
|
||||
// [2021-05-23T08:38:48Z DEBUG hyper::proto::h1::conn] incoming body is empty
|
||||
// [2021-05-23T08:38:48Z DEBUG hyper::client::pool] pooling idle connection
|
||||
// for ("https", dev-vocodes-private-uploads.storage.googleapis.com)
|
||||
// [2021-05-23T08:38:48Z DEBUG reqwest::async_impl::client] response '200 OK'
|
||||
// for https://dev-vocodes-private-uploads.storage.googleapis.com/95497399bf361e032cee4e180ee605b9dd5e1baa5ff31faefa42119fe19a6664
|
||||
// [2021-05-23T08:38:48Z INFO tts_download_job::util::bucket_client] upload code: 200
|
||||
let object_name = format!(
|
||||
"{}.bin",
|
||||
&private_bucket_hash,
|
||||
"/{}", private_bucket_hash
|
||||
);
|
||||
|
||||
info!("Destination bucket path: {}", object_name);
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
use anyhow::bail;
|
||||
use log::info;
|
||||
use log::warn;
|
||||
use s3::bucket::Bucket;
|
||||
use s3::creds::Credentials;
|
||||
use s3::region::Region;
|
||||
use std::path::{PathBuf, Path};
|
||||
use std::str::FromStr;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::path::{PathBuf, Path};
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct BucketClient {
|
||||
@@ -33,7 +34,10 @@ impl BucketClient {
|
||||
region: region_name.to_owned(),
|
||||
endpoint: "https://storage.googleapis.com".to_owned(),
|
||||
};
|
||||
let bucket = Bucket::new(&bucket_name, region, credentials)?;
|
||||
let mut bucket = Bucket::new(&bucket_name, region, credentials)?;
|
||||
|
||||
//bucket.set_path_style();
|
||||
//bucket.set_subdomain_style();
|
||||
|
||||
Ok(Self {
|
||||
bucket,
|
||||
@@ -43,13 +47,14 @@ impl BucketClient {
|
||||
pub async fn upload_file(&self, object_name: &str, bytes: &[u8]) -> anyhow::Result<()> {
|
||||
info!("Filename for bucket: {}", object_name);
|
||||
|
||||
let (body_bytes, code) = self.bucket.put_object(object_name, bytes).await?;
|
||||
let (body_bytes, code) = self.bucket.put_object_with_content_type(object_name, bytes, "application/zip").await?;
|
||||
|
||||
info!("upload code: {}", code);
|
||||
|
||||
let body = String::from_utf8(body_bytes)?;
|
||||
|
||||
info!("upload body: {}", body);
|
||||
if code != 200 {
|
||||
let body = String::from_utf8(body_bytes)?;
|
||||
warn!("upload body: {}", body);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user