introduce Batch size and a README
This commit is contained in:
parent
ea40103538
commit
bde794d745
3 changed files with 13 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
|||
use std::fs;
|
||||
use serde::Deserialize;
|
||||
use std::path::Path;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use reqwest::blocking::Client;
|
||||
use std::error::Error;
|
||||
|
||||
|
@ -9,6 +10,7 @@ struct Config {
|
|||
access_token: String,
|
||||
visibility: String, // Should be "unlisted"
|
||||
default_text: String,
|
||||
batch_size: usize,
|
||||
}
|
||||
|
||||
fn load_config() -> Result<Config, Box<dyn Error>> {
|
||||
|
@ -92,9 +94,9 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
let config = load_config()?;
|
||||
let images = get_jpeg_files(&args[1]);
|
||||
let client = Client::new();
|
||||
let total_batches = (images.len() + 19) / 20;
|
||||
let total_batches = (images.len() + config.batch_size - 1) / config.batch_size;
|
||||
|
||||
for (i, chunk) in images.chunks(20).enumerate() {
|
||||
for (i, chunk) in images.chunks(config.batch_size).enumerate() {
|
||||
upload_images_batch(&client, &config, chunk, i + 1, total_batches, &title)?;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue