Skip to content

Commit f25fbd6

Browse files
committed
Get uploader from config instead of app
This removes the need for an app instance in the render-readmes script
1 parent b0f014d commit f25fbd6

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/bin/render-readmes.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@ use flate2::read::GzDecoder;
2929
use std::env;
3030
use std::io::{Cursor, Read};
3131
use std::path::Path;
32-
use std::sync::Arc;
3332
use std::thread;
3433
use tar::Archive;
3534
use url::Url;
3635

37-
use cargo_registry::{App, Config, Version};
36+
use cargo_registry::{Config, Version};
3837
use cargo_registry::version::EncodableVersion;
3938
use cargo_registry::schema::*;
4039
use cargo_registry::render::markdown_to_html;
@@ -43,7 +42,6 @@ const DEFAULT_PAGE_SIZE: i64 = 25;
4342

4443
fn main() {
4544
let config: Config = Default::default();
46-
let app = Arc::new(App::new(&config));
4745
let conn = cargo_registry::db::connect_now().unwrap();
4846
let versions_count = versions::table
4947
.select(versions::all_columns)
@@ -72,10 +70,10 @@ fn main() {
7270
.collect();
7371
let mut tasks = Vec::with_capacity(page_size as usize);
7472
for version in versions {
75-
let app = app.clone();
73+
let config = config.clone();
7674
let handle = thread::spawn(move || {
7775
println!("[{}-{}] Rendering README...", version.krate, version.num);
78-
let readme = get_readme(app.clone(), &version);
76+
let readme = get_readme(&config, &version);
7977
if readme.is_none() {
8078
return;
8179
}
@@ -88,7 +86,7 @@ fn main() {
8886
);
8987
let readme_len = readme.len();
9088
let mut body = Cursor::new(readme.into_bytes());
91-
app.config
89+
config
9290
.uploader
9391
.upload(
9492
Easy::new(),
@@ -114,9 +112,9 @@ fn main() {
114112
}
115113

116114
/// Renders the readme of an uploaded crate version.
117-
fn get_readme(app: Arc<App>, version: &EncodableVersion) -> Option<String> {
115+
fn get_readme(config: &Config, version: &EncodableVersion) -> Option<String> {
118116
let mut handle = Easy::new();
119-
let location = match app.config.uploader.crate_location(
117+
let location = match config.uploader.crate_location(
120118
&version.krate,
121119
&version.num,
122120
) {

0 commit comments

Comments
 (0)