Skip to content

Commit

Permalink
Bump backend deps
Browse files Browse the repository at this point in the history
 * Update code to compile with new versions
  • Loading branch information
Ameobea committed Feb 11, 2024
1 parent 35518e4 commit 010e725
Show file tree
Hide file tree
Showing 17 changed files with 291 additions and 321 deletions.
537 changes: 252 additions & 285 deletions backend/Cargo.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ edition = "2021"
[dependencies]
dotenv = "0.15.0"

diesel = { version = "1.4.5", features = ["mysql", "chrono"] }
diesel = { version = "2.0", features = ["mysql", "chrono"] }

hex = "0.4"

itertools = "0.10"
itertools = "0.12"

lazy_static = "1.4.0"

Expand All @@ -21,9 +21,9 @@ hound = "3.4"

reqwest = { version = "0.11", features = ["gzip", "brotli"] }

rocket = { version = "0.5.0-rc.2", features = ["json"] }
rocket_sync_db_pools = { version = "0.1.0-rc.2", features = ["diesel_mysql_pool"] }
rocket_async_compression = "0.2.0"
rocket = { version = "0.5", features = ["json"] }
rocket_sync_db_pools = { version = "0.1", features = ["diesel_mysql_pool"] }
rocket_async_compression = "0.5.0"

serde_json = "1.0"
serde = "1.0"
Expand All @@ -33,9 +33,9 @@ sha2 = "0.10"

tokio = { version = "1.24", features = ["macros", "rt-multi-thread"] }

scrypt = "0.10.0"
base64 = "0.20.0"
scrypt = "0.11.0"
base64 = "0.21.0"

rust-s3 = { version = "0.32.3", features = [] }
rust-s3 = { version = "0.33", features = [] }
aws-region = { version = "0.25.0", features = ["serde"] }
urlencoding = "2.1"
2 changes: 1 addition & 1 deletion backend/src/db_util/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{

fn hash_password(password: &str) -> Result<String, scrypt::password_hash::Error> {
let salt = SaltString::generate(&mut OsRng);
let params = scrypt::Params::new(15, 2, 2).unwrap();
let params = scrypt::Params::new(15, 2, 2, scrypt::Params::RECOMMENDED_LEN).unwrap();
let hash = Scrypt
.hash_password_customized(
password.as_bytes(),
Expand Down
9 changes: 7 additions & 2 deletions backend/src/db_util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ pub mod private_sample_libraries;
// Facilitate getting the primary key of the last inserted item
//
// https://github.com/diesel-rs/diesel/issues/1011#issuecomment-315536931
no_arg_sql_function!(last_insert_id, diesel::types::Bigint);
sql_function! {
fn last_insert_id() -> BigInt;
}

pub fn get_and_create_tag_ids(conn: &MysqlConnection, tags: Vec<String>) -> QueryResult<Vec<i64>> {
pub fn get_and_create_tag_ids(
conn: &mut MysqlConnection,
tags: Vec<String>,
) -> QueryResult<Vec<i64>> {
use crate::schema::tags;

let tags_clone = tags.clone();
Expand Down
4 changes: 2 additions & 2 deletions backend/src/models/compositions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct NewCompositionRequest {
}

#[derive(Insertable)]
#[table_name = "compositions"]
#[diesel(table_name = compositions)]
pub struct NewComposition {
pub title: String,
pub description: String,
Expand Down Expand Up @@ -42,7 +42,7 @@ pub struct Composition {
}

#[derive(Insertable)]
#[table_name = "compositions_tags"]
#[diesel(table_name = compositions_tags)]
pub struct NewCompositionTag {
pub composition_id: i64,
pub tag_id: i64,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/models/effects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct Effect {
}

#[derive(Deserialize, Insertable)]
#[table_name = "effects"]
#[diesel(table_name = effects)]
pub struct InsertableEffect {
pub title: String,
pub description: String,
Expand Down
4 changes: 2 additions & 2 deletions backend/src/models/looper_preset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct LooperPresetDescriptor {
}

#[derive(Insertable)]
#[table_name = "looper_presets"]
#[diesel(table_name = looper_presets)]
pub struct NewLooperPreset {
pub name: String,
pub description: String,
Expand All @@ -50,7 +50,7 @@ pub struct NewLooperPreset {
}

#[derive(Insertable)]
#[table_name = "looper_presets_tags"]
#[diesel(table_name = looper_presets_tags)]
pub struct NewLooperPresetTag {
pub looper_preset_id: i64,
pub tag_id: i64,
Expand Down
4 changes: 2 additions & 2 deletions backend/src/models/midi_composition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct SerializedMIDIEditorState {
}

#[derive(Insertable)]
#[table_name = "midi_compositions"]
#[diesel(table_name = midi_compositions)]
pub struct InsertableMIDIComposition {
pub name: String,
pub description: String,
Expand Down Expand Up @@ -75,7 +75,7 @@ pub struct MIDIComposition {
}

#[derive(Insertable)]
#[table_name = "midi_compositions_tags"]
#[diesel(table_name = midi_compositions_tags)]
pub struct NewMidiCompositionTag {
pub midi_composition_id: i64,
pub tag_id: i64,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/models/remote_samples.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::schema::*;

#[derive(Clone, PartialEq, Insertable, Queryable, Serialize)]
#[table_name = "remote_sample_urls"]
#[diesel(table_name = remote_sample_urls)]
#[serde(rename_all = "camelCase")]
pub struct RemoteSample {
pub id: String,
Expand Down
4 changes: 2 additions & 2 deletions backend/src/models/synth_preset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ pub struct ReceivedSynthPresetEntry {
}

#[derive(Insertable)]
#[table_name = "synth_presets"]
#[diesel(table_name = synth_presets)]
pub struct NewSynthPresetEntry {
pub title: String,
pub description: String,
Expand All @@ -272,7 +272,7 @@ pub struct UserProvidedNewSynthVoicePreset {
}

#[derive(Insertable)]
#[table_name = "voice_presets"]
#[diesel(table_name = voice_presets)]
pub struct NewSynthVoicePresetEntry {
pub title: String,
pub description: String,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/models/tags.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::schema::tags;

#[derive(Insertable)]
#[table_name = "tags"]
#[diesel(table_name = tags)]
pub struct NewTag {
pub tag: String,
}
Expand Down
4 changes: 2 additions & 2 deletions backend/src/models/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ use rocket::{
use crate::schema::{login_tokens, users};

#[derive(Insertable)]
#[table_name = "users"]
#[diesel(table_name = users)]
pub struct NewUser {
pub username: String,
pub hashed_password: String,
}

#[derive(Insertable)]
#[table_name = "login_tokens"]
#[diesel(table_name = login_tokens)]
pub struct NewLoginToken {
pub user_id: i64,
pub token: String,
Expand Down
4 changes: 2 additions & 2 deletions backend/src/models/wavetable_preset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct SaveWavetablePresetRequest {
}

#[derive(Insertable)]
#[table_name = "wavetable_presets"]
#[diesel(table_name = wavetable_presets)]
pub struct NewWavetablePreset {
pub name: String,
pub description: String,
Expand All @@ -70,7 +70,7 @@ pub struct NewWavetablePreset {
}

#[derive(Insertable)]
#[table_name = "wavetable_presets_tags"]
#[diesel(table_name = wavetable_presets_tags)]
pub struct NewWavetablePresetTag {
pub wavetable_preset_id: i64,
pub tag_id: i64,
Expand Down
5 changes: 2 additions & 3 deletions backend/src/routes/looper_preset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ pub async fn create_looper_preset(

let created_preset_id = conn
.run(move |conn| -> QueryResult<i64> {
let conn = &*conn;
conn.transaction(move || {
conn.transaction(move |conn| {
diesel::insert_into(looper_presets::table)
.values(NewLooperPreset {
name,
Expand All @@ -143,7 +142,7 @@ pub async fn create_looper_preset(
user_id,
})
.execute(conn)?;
let created_preset_id = diesel::select(last_insert_id).first(conn)?;
let created_preset_id = diesel::select(last_insert_id()).first(conn)?;

// Insert tags
let tag_count = tags.len();
Expand Down
4 changes: 2 additions & 2 deletions backend/src/routes/midi_composition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ pub async fn save_midi_composition(
let tags = composition.tags.clone();

conn.run(|conn| {
conn.transaction(|| -> QueryResult<()> {
conn.transaction(|conn| -> QueryResult<()> {
diesel::insert_into(midi_compositions::table)
.values(insertable_comp)
.execute(conn)?;
let created_preset_id = diesel::select(last_insert_id).first(conn)?;
let created_preset_id = diesel::select(last_insert_id()).first(conn)?;

// Insert tags
let tag_count = tags.len();
Expand Down
4 changes: 2 additions & 2 deletions backend/src/routes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ pub async fn save_composition(

let saved_composition_id = conn
.run(move |conn| {
conn.transaction(|| -> QueryResult<i64> {
conn.transaction(|conn| -> QueryResult<i64> {
diesel::insert_into(schema::compositions::table)
.values(&new_composition)
.execute(conn)?;

let saved_comp_id = diesel::select(last_insert_id).first(conn)?;
let saved_comp_id = diesel::select(last_insert_id()).first(conn)?;

// Insert tags
let tag_count = tags.len();
Expand Down
5 changes: 2 additions & 3 deletions backend/src/routes/wavetable_preset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ pub async fn create_wavetable_preset(
.run(move |conn| -> QueryResult<i64> {
use crate::schema::{wavetable_presets, wavetable_presets_tags};

let conn = &*conn;
conn.transaction(move || {
conn.transaction(move |conn| {
diesel::insert_into(wavetable_presets::table)
.values(NewWavetablePreset {
name,
Expand All @@ -147,7 +146,7 @@ pub async fn create_wavetable_preset(
user_id,
})
.execute(conn)?;
let created_preset_id = diesel::select(last_insert_id).first(conn)?;
let created_preset_id = diesel::select(last_insert_id()).first(conn)?;

// Insert tags
let tag_count = tags.len();
Expand Down

0 comments on commit 010e725

Please sign in to comment.