Compare commits

..

No commits in common. "39adc3fb62d5783e08ac57aa8784afebbb50e067" and "0fa5fd4d0465ef98ed31176ed1741e63b8927cc2" have entirely different histories.

4 changed files with 4 additions and 9 deletions

View File

@ -1,3 +1,2 @@
[settings]
base_directory = "/strg/drw"
bind_address = "127.0.0.1:3012"

View File

@ -10,7 +10,6 @@ pub struct Config {
#[derive(Deserialize)]
pub struct Settings {
pub base_directory: String,
pub bind_address: String,
}
pub fn read_config() -> Result<Config, Box<dyn std::error::Error>> {

View File

@ -15,7 +15,6 @@ pub async fn list_files(
let template = ListTemplate {
files: files.to_vec(),
};
HtmlTemplate(template)
}
@ -23,11 +22,11 @@ pub async fn rescan_files(
base_path: String,
State(state): State<Arc<RwLock<Vec<utils::FileEntry>>>>,
) -> impl IntoResponse {
let new_files = utils::find_files(&base_path).expect("Error trying to refresh list");
let mut files = state.write().unwrap(); // Adquire lock
files.clear();
files.extend(new_files);
files.extend(utils::find_files(&base_path).expect("Error trying to refresh list"));
"Files rescanned successfuly"
}

View File

@ -30,9 +30,7 @@ async fn main() {
)
.with_state(files);
let listener = TcpListener::bind(config.settings.bind_address)
.await
.unwrap();
let listener = TcpListener::bind("127.0.0.1:3004").await.unwrap();
println!("Listening on {}", listener.local_addr().unwrap());
axum::serve(listener, app).await.unwrap();