Create a mock file host for dev, Fix mod creation route (#38)

* fix(mod-creation): fix actix server data & mod creation route

* feat(file-host): implement mock file hosting

This implements a mock file hosting system backed by the system's
filesystem.  It mirrors the API of the backblaze integration, but
puts the files directly on disk in the path specified by the
MOCK_FILE_PATH environment variable (defaults to /tmp/modrinth).

The mock file hosting is enabled by default using cargo features
to allow people to work on modrinth without access to a valid
backblaze account and setup.  To enable backblaze, specify the
cargo feature "backblaze" when running, ex. `cargo run --features
backblaze`.

* feat(file-hosting): implement basic backblaze API error handling

* fix(mod-creation): fix extension parsing, use base62 ids for paths
fix(file-hosting): reduce unnecessary allocations

* fix: fix auth with docker mongodb

* fix: fix failing checks

* fix: remove testing files
This commit is contained in:
Aeledfyr
2020-07-16 23:06:58 -05:00
committed by GitHub
parent 39b1435725
commit 95339a8338
9 changed files with 211 additions and 88 deletions

View File

@@ -23,7 +23,7 @@ async fn main() -> std::io::Result<()> {
let client = database::connect()
.await
.expect("Database connection failed");
let client_ref = web::Data::new(client.clone());
let client_ref = client.clone();
//File Hosting Initializer
let authorization_data = file_hosting::authorize_account(
@@ -39,9 +39,6 @@ async fn main() -> std::io::Result<()> {
.await
.unwrap();
let authorization_data_ref = web::Data::new(authorization_data);
let upload_url_data_ref = web::Data::new(upload_url_data);
// Get executable path
let mut exe_path = env::current_exe()?.parent().unwrap().to_path_buf();
// Create the path to the index lock file
@@ -68,10 +65,11 @@ async fn main() -> std::io::Result<()> {
.wrap(Logger::default())
.wrap(Logger::new("%a %{User-Agent}i"))
.data(client_ref.clone())
.data(authorization_data_ref.clone())
.data(upload_url_data_ref.clone())
.data(authorization_data.clone())
.data(upload_url_data.clone())
.service(routes::index_get)
.service(routes::mod_search)
.service(routes::mod_create)
.default_service(web::get().to(routes::not_found))
})
.bind(dotenv::var("BIND_ADDR").unwrap())?