Compare commits
6 commits
5f4158e27d
...
7825f38e7a
Author | SHA1 | Date | |
---|---|---|---|
7825f38e7a | |||
122643c630 | |||
1ccaab9578 | |||
91cbca6b15 | |||
814aaad260 | |||
1dc9f4c877 |
9 changed files with 82 additions and 18 deletions
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"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"
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "INSERT INTO records (cache_name, max_downloads)\nVALUES (?, ?);\n",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "dcad7587b9bd5d84025db4e22c90d2ba0210edeaff5235a877e92235384f2c57"
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"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"
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -16,5 +16,5 @@ mkShell rec {
|
|||
sqlite
|
||||
] ++ additionalBuildInputs;
|
||||
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
|
||||
DATABASE_URL = "sqlite:testing.db";
|
||||
DATABASE_URL = "sqlite://.cache/data";
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use axum::{extract::State, response::IntoResponse, routing::get, Json, Router};
|
||||
use axum::{extract::State, response::IntoResponse, routing::get, Router};
|
||||
use reqwest::StatusCode;
|
||||
|
||||
use crate::{db::CacheRecordName, templates::LinkListTemplate, AppState};
|
||||
|
|
|
@ -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(format!("{}.zip", &cache_name));
|
||||
let archive_path = Path::new(".cache/serve").join(&cache_name);
|
||||
|
||||
tracing::debug!("Zipping: {:?}", &archive_path);
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ impl AppState {
|
|||
pub fn new() -> Self {
|
||||
Self {
|
||||
pool: SqlitePool::connect_lazy_with(
|
||||
SqliteConnectOptions::from_str("sqlite:testing.db")
|
||||
SqliteConnectOptions::from_str("sqlite://.cache/data")
|
||||
.expect("Invalid Database String"),
|
||||
),
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ pub static HXR_NAME: HeaderName = HeaderName::from_static(HXR_TEXT);
|
|||
|
||||
impl Header for HxRequest {
|
||||
fn name() -> &'static HeaderName {
|
||||
&FF_NAME
|
||||
&HXR_NAME
|
||||
}
|
||||
|
||||
fn decode<'i, I>(values: &mut I) -> Result<Self, headers::Error>
|
||||
|
|
Loading…
Reference in a new issue