feat: upload creates db record
This commit is contained in:
parent
47bc1b6016
commit
5a000e6b42
1 changed files with 16 additions and 0 deletions
|
@ -13,6 +13,7 @@ use sanitize_filename_reader_friendly::sanitize;
|
||||||
use tokio::io;
|
use tokio::io;
|
||||||
use tokio_util::{compat::FuturesAsyncWriteCompatExt, io::StreamReader};
|
use tokio_util::{compat::FuturesAsyncWriteCompatExt, io::StreamReader};
|
||||||
use tower_http::limit::RequestBodyLimitLayer;
|
use tower_http::limit::RequestBodyLimitLayer;
|
||||||
|
use tracing::debug;
|
||||||
|
|
||||||
use crate::{askama::DownloadLinkFragment, cache, util, AppState, UploadRecord};
|
use crate::{askama::DownloadLinkFragment, cache, util, AppState, UploadRecord};
|
||||||
|
|
||||||
|
@ -75,6 +76,21 @@ async fn upload_to_zip(
|
||||||
|
|
||||||
let record = UploadRecord::new(archive_path);
|
let record = UploadRecord::new(archive_path);
|
||||||
let mut records = state.records.lock().await;
|
let mut records = state.records.lock().await;
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut conn = state.pool.acquire().await.unwrap();
|
||||||
|
let path = record.file.clone().into_os_string().into_string().unwrap();
|
||||||
|
|
||||||
|
let id = sqlx::query_file!("queries/records/new.sql", path, 5)
|
||||||
|
.execute(&mut *conn)
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
.last_insert_rowid();
|
||||||
|
|
||||||
|
// TODO: Looks like I actually gotta store cache_name lmfao
|
||||||
|
debug!("Saved Record {id}");
|
||||||
|
}
|
||||||
|
|
||||||
records.insert(cache_name.clone(), record.clone());
|
records.insert(cache_name.clone(), record.clone());
|
||||||
|
|
||||||
let records_cache = records.clone();
|
let records_cache = records.clone();
|
||||||
|
|
Loading…
Reference in a new issue