Update dependencies, improve startup logging

This commit is contained in:
Cameron
2024-11-23 12:14:12 -05:00
parent 4899dc4967
commit 287a61ae3f
4 changed files with 856 additions and 485 deletions

View File

@@ -314,7 +314,7 @@ impl Handler<RefreshThumbnailsMessage> for StreamActor {
type Result = ();
fn handle(&mut self, _msg: RefreshThumbnailsMessage, _ctx: &mut Self::Context) -> Self::Result {
debug!("Refreshing thumbnails after upload");
info!("Refreshing thumbnails after upload");
create_thumbnails()
}
}

View File

@@ -26,6 +26,7 @@ use actix_web::{
web::{self, BufMut, BytesMut},
App, HttpRequest, HttpResponse, HttpServer, Responder,
};
use anyhow::Context;
use chrono::Utc;
use diesel::sqlite::Sqlite;
use notify::{Config, EventKind, RecommendedWatcher, RecursiveMode, Watcher};
@@ -139,19 +140,20 @@ async fn upload_image(
let mut file_path: Option<String> = None;
while let Some(Ok(mut part)) = payload.next().await {
let content_type = part.content_disposition();
debug!("{:?}", content_type);
if let Some(filename) = content_type.get_filename() {
debug!("Name: {:?}", filename);
file_name = Some(filename.to_string());
if let Some(content_type) = part.content_disposition() {
debug!("{:?}", content_type);
if let Some(filename) = content_type.get_filename() {
debug!("Name: {:?}", filename);
file_name = Some(filename.to_string());
while let Some(Ok(data)) = part.next().await {
file_content.put(data);
}
} else if content_type.get_name().map_or(false, |name| name == "path") {
while let Some(Ok(data)) = part.next().await {
if let Ok(path) = std::str::from_utf8(&data) {
file_path = Some(path.to_string())
while let Some(Ok(data)) = part.next().await {
file_content.put(data);
}
} else if content_type.get_name().map_or(false, |name| name == "path") {
while let Some(Ok(data)) = part.next().await {
if let Ok(path) = std::str::from_utf8(&data) {
file_path = Some(path.to_string())
}
}
}
}
@@ -462,7 +464,9 @@ fn is_video(entry: &DirEntry) -> bool {
}
fn main() -> std::io::Result<()> {
dotenv::dotenv().ok();
if let Err(err) = dotenv::dotenv() {
println!("Error parsing .env {:?}", err);
}
env_logger::init();
run_migrations(&mut connect()).expect("Failed to run migrations");
@@ -544,7 +548,9 @@ fn watch_files() {
let base_str = dotenv::var("BASE_PATH").unwrap();
let base_path = Path::new(&base_str);
watcher.watch(base_path, RecursiveMode::Recursive).unwrap();
watcher.watch(base_path, RecursiveMode::Recursive)
.context(format!("Unable to watch BASE_PATH: '{}'", base_str))
.unwrap();
loop {
let ev = wrx.recv();