Compare commits

..

No commits in common. "7825f38e7aa98af4b1651761f20f24cb724a8c55" and "5f4158e27d132e889adedf541b10c0ef93e7d52b" have entirely different histories.

9 changed files with 18 additions and 82 deletions

View file

@ -1,38 +0,0 @@
{
"db_name": "SQLite",
"query": "INSERT INTO records (cache_name, max_downloads)\nVALUES (?, ?)\nRETURNING\n cache_name,\n uploaded AS \"uploaded: _\",\n downloads AS \"downloads: i32\",\n max_downloads AS \"max_downloads: i32\";\n",
"describe": {
"columns": [
{
"name": "cache_name",
"ordinal": 0,
"type_info": "Text"
},
{
"name": "uploaded: _",
"ordinal": 1,
"type_info": "Text"
},
{
"name": "downloads: i32",
"ordinal": 2,
"type_info": "Integer"
},
{
"name": "max_downloads: i32",
"ordinal": 3,
"type_info": "Integer"
}
],
"parameters": {
"Right": 2
},
"nullable": [
false,
false,
false,
false
]
},
"hash": "7364fac4efc7b1872f8298bb007191caed687d5c6a0770486a329a24085b2ab2"
}

View file

@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "INSERT INTO records (cache_name, max_downloads)\nVALUES (?, ?);\n",
"describe": {
"columns": [],
"parameters": {
"Right": 2
},
"nullable": []
},
"hash": "dcad7587b9bd5d84025db4e22c90d2ba0210edeaff5235a877e92235384f2c57"
}

View file

@ -1,38 +0,0 @@
{
"db_name": "SQLite",
"query": "SELECT\n cache_name,\n uploaded AS \"uploaded: _\",\n downloads AS \"downloads: i32\",\n max_downloads AS \"max_downloads: i32\"\nFROM records\nWHERE cache_name = ?;\n",
"describe": {
"columns": [
{
"name": "cache_name",
"ordinal": 0,
"type_info": "Text"
},
{
"name": "uploaded: _",
"ordinal": 1,
"type_info": "Text"
},
{
"name": "downloads: i32",
"ordinal": 2,
"type_info": "Integer"
},
{
"name": "max_downloads: i32",
"ordinal": 3,
"type_info": "Integer"
}
],
"parameters": {
"Right": 1
},
"nullable": [
false,
false,
false,
false
]
},
"hash": "f910a524c457442564a8d484fc00a277ae5cb73444e5748af0bf0d629048fa17"
}

View file

@ -3,4 +3,4 @@ SET downloads = downloads + 1
WHERE
cache_name = ?
AND downloads < max_downloads
AND julianday('now') - julianday(uploaded) < 5;
AND julianday('now') - julianday(uploaded) > 5;

View file

@ -16,5 +16,5 @@ mkShell rec {
sqlite
] ++ additionalBuildInputs;
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
DATABASE_URL = "sqlite://.cache/data";
DATABASE_URL = "sqlite:testing.db";
}

View file

@ -1,4 +1,4 @@
use axum::{extract::State, response::IntoResponse, routing::get, Router};
use axum::{extract::State, response::IntoResponse, routing::get, Json, Router};
use reqwest::StatusCode;
use crate::{db::CacheRecordName, templates::LinkListTemplate, AppState};

View file

@ -32,7 +32,7 @@ async fn upload_to_zip(
) -> Result<Response, (StatusCode, String)> {
let cache_name = util::get_random_name(10);
let archive_path = Path::new(".cache/serve").join(&cache_name);
let archive_path = Path::new(".cache/serve").join(format!("{}.zip", &cache_name));
tracing::debug!("Zipping: {:?}", &archive_path);

View file

@ -55,7 +55,7 @@ impl AppState {
pub fn new() -> Self {
Self {
pool: SqlitePool::connect_lazy_with(
SqliteConnectOptions::from_str("sqlite://.cache/data")
SqliteConnectOptions::from_str("sqlite:testing.db")
.expect("Invalid Database String"),
),
}

View file

@ -41,7 +41,7 @@ pub static HXR_NAME: HeaderName = HeaderName::from_static(HXR_TEXT);
impl Header for HxRequest {
fn name() -> &'static HeaderName {
&HXR_NAME
&FF_NAME
}
fn decode<'i, I>(values: &mut I) -> Result<Self, headers::Error>