Skip to content
This repository was archived by the owner on Oct 19, 2024. It is now read-only.

Commit e7b41f9

Browse files
committed
Urgent fixes
1 parent dd0aed4 commit e7b41f9

File tree

6 files changed

+62
-50
lines changed

6 files changed

+62
-50
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "labrinth"
3-
version = "2.3.0"
3+
version = "2.3.1"
44
#Team members, please add your emails and usernames
55
authors = ["geometrically <[email protected]>", "Redblueflame <[email protected]>", "Aeledfyr <[email protected]>", "Charalampos Fanoulis <[email protected]>", "AppleTheGolden <[email protected]>"]
66
edition = "2018"

sqlx-data.json

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -877,27 +877,6 @@
877877
"nullable": []
878878
}
879879
},
880-
"331041c6a4f27f4a6ac2873332074c0127e7368c8ab803843760530d29aaef08": {
881-
"query": "SELECT id FROM versions\n WHERE (version_number = $1 AND mod_id = $2)",
882-
"describe": {
883-
"columns": [
884-
{
885-
"ordinal": 0,
886-
"name": "id",
887-
"type_info": "Int8"
888-
}
889-
],
890-
"parameters": {
891-
"Left": [
892-
"Text",
893-
"Int8"
894-
]
895-
},
896-
"nullable": [
897-
false
898-
]
899-
}
900-
},
901880
"33a965c7dc615d3b701c05299889357db8dd36d378850625d2602ba471af4885": {
902881
"query": "\n UPDATE mods\n SET downloads = downloads + $1\n WHERE (id = $2)\n ",
903882
"describe": {
@@ -4471,6 +4450,33 @@
44714450
"nullable": []
44724451
}
44734452
},
4453+
"c265db2e2cc1ba34ca1f30a9401018eb7760c8f0bafb1e3a7576e62bc9d3f83a": {
4454+
"query": "SELECT id, mod_id FROM versions\n WHERE (version_number = $1 AND mod_id = $2)",
4455+
"describe": {
4456+
"columns": [
4457+
{
4458+
"ordinal": 0,
4459+
"name": "id",
4460+
"type_info": "Int8"
4461+
},
4462+
{
4463+
"ordinal": 1,
4464+
"name": "mod_id",
4465+
"type_info": "Int8"
4466+
}
4467+
],
4468+
"parameters": {
4469+
"Left": [
4470+
"Text",
4471+
"Int8"
4472+
]
4473+
},
4474+
"nullable": [
4475+
false,
4476+
false
4477+
]
4478+
}
4479+
},
44744480
"c3dcb5a8b798ea6c0922698a007dbc8ab549f5f85bad780da59163f4d6371238": {
44754481
"query": "\n SELECT id FROM mods\n WHERE status = (\n SELECT id FROM statuses WHERE status = $1\n )\n ORDER BY updated ASC\n LIMIT $2;\n ",
44764482
"describe": {

src/routes/admin.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
use crate::models::ids::ProjectId;
12
use crate::routes::ApiError;
23
use crate::util::guards::admin_key_guard;
34
use actix_web::{patch, web, HttpResponse};
45
use serde::Deserialize;
56
use sqlx::PgPool;
6-
use crate::models::ids::ProjectId;
77

88
#[derive(Deserialize)]
99
pub struct DownloadBody {
@@ -18,17 +18,19 @@ pub async fn count_download(
1818
pool: web::Data<PgPool>,
1919
download_body: web::Json<DownloadBody>,
2020
) -> Result<HttpResponse, ApiError> {
21-
let project_id : crate::database::models::ids::ProjectId = download_body.hash.into();
21+
let project_id: crate::database::models::ids::ProjectId =
22+
download_body.hash.into();
2223

23-
let version_id = if let Some(version) = sqlx::query!(
24-
"SELECT id FROM versions
24+
let (version_id, project_id) = if let Some(version) = sqlx::query!(
25+
"SELECT id, mod_id FROM versions
2526
WHERE (version_number = $1 AND mod_id = $2)",
2627
download_body.version_name,
27-
project_id as crate::database::models::ids::ProjectId
28+
project_id as crate::database::models::ids::ProjectId
2829
)
29-
.fetch_optional(pool.as_ref())
30-
.await? {
31-
version.id
30+
.fetch_optional(pool.as_ref())
31+
.await?
32+
{
33+
(version.id, version.mod_id)
3234
} else if let Some(version) = sqlx::query!(
3335
"
3436
SELECT v.id id, v.mod_id project_id FROM files f
@@ -37,11 +39,14 @@ pub async fn count_download(
3739
",
3840
download_body.url,
3941
)
40-
.fetch_optional(pool.as_ref())
41-
.await? {
42-
version.id
42+
.fetch_optional(pool.as_ref())
43+
.await?
44+
{
45+
(version.id, version.project_id)
4346
} else {
44-
return Err(ApiError::InvalidInput("Specified version does not exist!".to_string()));
47+
return Err(ApiError::InvalidInput(
48+
"Specified version does not exist!".to_string(),
49+
));
4550
};
4651

4752
let mut transaction = pool.begin().await?;
@@ -59,7 +64,7 @@ pub async fn count_download(
5964
"UPDATE mods
6065
SET downloads = downloads + 1
6166
WHERE (id = $1)",
62-
version_id
67+
project_id
6368
)
6469
.execute(&mut *transaction)
6570
.await?;

src/routes/auth.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,13 @@ pub async fn auth_callback(
145145
.await?;
146146

147147
if let Some(result) = result_option {
148-
let now = OffsetDateTime::now_utc();
149-
let duration = now - result.expires;
150-
151-
if duration.whole_seconds() < 0 {
152-
return Err(AuthorizationError::InvalidCredentials);
153-
}
148+
// let now = OffsetDateTime::now_utc();
149+
// TODO: redo this condition later..
150+
// let duration = now - result.expires;
151+
//
152+
// if duration.whole_seconds() < 0 {
153+
// return Err(AuthorizationError::InvalidCredentials);
154+
// }
154155

155156
sqlx::query!(
156157
"

src/routes/projects.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -445,14 +445,14 @@ pub async fn project_edit(
445445
} else if !project_item.status.is_searchable()
446446
&& status.is_searchable()
447447
{
448-
let index_project =
449-
crate::search::indexing::local_import::query_one(
450-
id,
451-
&mut *transaction,
452-
)
453-
.await?;
454-
455-
indexing_queue.add(index_project);
448+
// let index_project =
449+
// crate::search::indexing::local_import::query_one(
450+
// id,
451+
// &mut *transaction,
452+
// )
453+
// .await?;
454+
//
455+
// indexing_queue.add(index_project);
456456
}
457457
}
458458

0 commit comments

Comments
 (0)