Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add riscv build support #593

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
973 changes: 655 additions & 318 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dim-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ ignore = "0.4.20"
image = "0.24.3"
itertools = "0.10.3"
lazy_static = "1.4.0"
libsqlite3-sys = { version = "^0.24.0" }
libsqlite3-sys = { version = "0.26.0" }
notify = "5.0.0"
once_cell = "1.8.0"
parking_lot = "0.12.0"
@@ -56,9 +56,9 @@ reqwest = { version = "0.11.0", features = [
"rustls-tls",
"brotli",
], default-features = false }
rusqlite = { version = "0.27.0", features = ["hooks"] }
rusqlite = { version = "0.29.0", features = ["hooks"] }
rust-embed = "^5.9.0"
sqlx = { version = "0.5", features = ["runtime-tokio-rustls"] }
sqlx = { version = "0.7", features = ["runtime-tokio-rustls"] }
thiserror = "1.0.30"
tokio = { version = "1", features = ["rt", "signal", "full", "tracing"] }
tokio-stream = "0.1.12"
6 changes: 3 additions & 3 deletions dim-database/Cargo.toml
Original file line number Diff line number Diff line change
@@ -14,10 +14,10 @@ serde_derive = "^1"
serde_json = "^1"
lazy_static = "^1"
tracing = "0.1.29"
ring = "^0.16.11"
ring = "^0.17.5"
uuid = { version = "0.8.1", features = ["v4"] }
cfg-if = "1.0.0"
sqlx = { version = "0.5", features = ["runtime-tokio-rustls", "sqlite"] }
sqlx = { version = "0.7", features = ["runtime-tokio-rustls", "sqlite"] }
once_cell = "1.8.0"
tokio = "1.20.4"
base64 = "0.13.0"
@@ -29,5 +29,5 @@ displaydoc = "0.2.3"
tokio = { version = "1", default-features = false, features = ["rt", "macros"] }

[build-dependencies]
sqlx = { version = "0.5", features = ["runtime-tokio-rustls"] }
sqlx = { version = "0.7", features = ["runtime-tokio-rustls"] }
tokio = "1.20.4"
20 changes: 10 additions & 10 deletions dim-database/src/asset.rs
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ impl Asset {
) -> Result<Self, DatabaseError> {
Ok(
sqlx::query_as!(Asset, "SELECT * FROM assets WHERE id = ?", id)
.fetch_one(&mut *conn)
.fetch_one(conn.as_mut())
.await?,
)
}
@@ -32,7 +32,7 @@ impl Asset {
WHERE users.id = ?"#,
uid
)
.fetch_one(&mut *conn)
.fetch_one(conn.as_mut())
.await?)
}

@@ -47,7 +47,7 @@ impl Asset {
media_id,
self.id
)
.fetch_one(&mut *conn)
.fetch_one(conn.as_mut())
.await?
.id)
}
@@ -63,7 +63,7 @@ impl Asset {
media_id,
self.id
)
.fetch_one(&mut *conn)
.fetch_one(conn.as_mut())
.await?
.id)
}
@@ -77,7 +77,7 @@ impl Asset {
r#"SELECT remote_url as "remote_url!" FROM assets WHERE Local_path = ?"#,
cleaned_path
)
.fetch_one(&mut *conn)
.fetch_one(conn.as_mut())
.await?
.remote_url)
}
@@ -109,7 +109,7 @@ impl InsertableAsset {

if let Ok(x) =
sqlx::query_as_unchecked!(Asset, "SELECT * FROM assets WHERE remote_url = ?", url)
.fetch_one(&mut *conn)
.fetch_one(conn.as_mut())
.await
{
return Ok(x);
@@ -122,7 +122,7 @@ impl InsertableAsset {
self.local_path,
self.file_ext
)
.execute(&mut *conn)
.execute(conn.as_mut())
.await?;

// NOTE: asset is guaranteed to be in the table if we get here
@@ -131,7 +131,7 @@ impl InsertableAsset {
r#"SELECT id as "id!", remote_url, local_path, file_ext FROM assets WHERE remote_url = ?"#,
url
)
.fetch_one(&mut *conn)
.fetch_one(conn.as_mut())
.await?;

Ok(result)
@@ -148,7 +148,7 @@ impl InsertableAsset {
self.local_path,
self.file_ext
)
.execute(&mut *conn)
.execute(conn.as_mut())
.await?
.last_insert_rowid();

@@ -157,7 +157,7 @@ impl InsertableAsset {
r#"SELECT id as "id!", remote_url, local_path, file_ext FROM assets WHERE id = ?"#,
id
)
.fetch_one(&mut *conn)
.fetch_one(conn.as_mut())
.await?;

Ok(result)
6 changes: 3 additions & 3 deletions dim-database/src/compact_mediafile.rs
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ impl CompactMediafile {
WHERE library_id = ? AND media_id IS NULL"#,
library_id
)
.fetch_all(tx)
.fetch_all(tx.as_mut())
.await?
.into_iter()
.map(Into::into)
@@ -71,7 +71,7 @@ impl CompactMediafile {
WHERE mediafile.media_id = ?"#,
media_id
)
.fetch_all(tx)
.fetch_all(tx.as_mut())
.await?
.into_iter()
.map(Into::into)
@@ -93,7 +93,7 @@ impl CompactMediafile {
",
tv_id
)
.fetch_all(&mut *tx)
.fetch_all(tx.as_mut())
.await?
.into_iter()
.map(Into::into)
40 changes: 20 additions & 20 deletions dim-database/src/episode.rs
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ impl Episode {
ORDER BY episode_ ASC"#,
season_id
)
.fetch_one(&mut *conn)
.fetch_one(conn.as_mut())
.await?;

let ep = Media::get(conn, wrapper.id).await?;
@@ -67,7 +67,7 @@ impl Episode {
LIMIT 1"#,
tv_id
)
.fetch_one(&mut *conn)
.fetch_one(conn.as_mut())
.await?;

let ep = Media::get(conn, wrapper.id).await?;
@@ -95,11 +95,11 @@ impl Episode {
ORDER BY season.season_number, episode.episode_"#,
tv_show_id
)
.fetch_all(&mut *conn)
.fetch_all(conn.as_mut())
.await?;

for wrapper in wrappers {
if let Ok(episode) = Media::get(&mut *conn, wrapper.id as i64).await {
if let Ok(episode) = Media::get(conn, wrapper.id as i64).await {
episodes.push(wrapper.into_episode(episode))
}
}
@@ -122,13 +122,13 @@ impl Episode {
r#"SELECT id as "id!", episode_, seasonid FROM episode WHERE seasonid = ?"#,
season_id
)
.fetch_all(&mut *conn)
.fetch_all(conn.as_mut())
.await?;

let mut episodes = vec![];

for wrapper in wrappers {
if let Ok(episode) = Media::get(&mut *conn, wrapper.id as i64).await {
if let Ok(episode) = Media::get(conn, wrapper.id as i64).await {
episodes.push(wrapper.into_episode(episode))
}
}
@@ -160,7 +160,7 @@ impl Episode {
season_num,
ep_num
)
.fetch_one(&mut *conn)
.fetch_one(conn.as_mut())
.await?;

let ep = Media::get(conn, wrapper.id as i64).await?;
@@ -178,7 +178,7 @@ impl Episode {
WHERE episode.id = ?"#,
episode_id
)
.fetch_one(&mut *conn)
.fetch_one(conn.as_mut())
.await?;

let ep = Media::get(conn, wrapper.id as i64).await?;
@@ -202,7 +202,7 @@ impl Episode {
WHERE episode.id = ?",
episode_id
)
.fetch_one(&mut *conn)
.fetch_one(conn.as_mut())
.await?;

Ok((result.season, result.episode))
@@ -217,7 +217,7 @@ impl Episode {
WHERE season.id = ?",
self.seasonid
)
.fetch_one(&mut *conn)
.fetch_one(conn.as_mut())
.await?;

Ok(record.season_number)
@@ -228,7 +228,7 @@ impl Episode {
&self,
conn: &mut crate::Transaction<'_>,
) -> Result<Episode, DatabaseError> {
let season_number = self.get_season_number(&mut *conn).await?;
let season_number = self.get_season_number(conn).await?;

let record = sqlx::query_as!(
EpisodeWrapper,
@@ -248,7 +248,7 @@ impl Episode {
season_number,
season_number
)
.fetch_one(&mut *conn)
.fetch_one(conn.as_mut())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like these changes are mostly pedantic.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try to see if it can be done in another way

Copy link
Author

@dista dista Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because Excutor trait is no longer impl for Transaction.

Some option:

  1. I see another pull request Bump sqlx to 0.7.3 #597 which use extra level of deref like this
-            .fetch_all(&mut *conn)
+           .fetch_all(&mut **conn)
  1. or we implement excutor back for Transaction.

which way do you prefer

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason there isn't a implementation of Executor for Transaction in sqlx now is that it couldn't exist. The changelog of sqlx explicitly said that dereferencing the Transaction is the way to do it now, so not sure how option 2 is going to work?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason there isn't a implementation of Executor for Transaction in sqlx now is that it couldn't exist. The changelog of sqlx explicitly said that dereferencing the Transaction is the way to do it now, so not sure how option 2 is going to work?

ha, seems so.

.await?;

let ep = Media::get(conn, record.id as i64).await?;
@@ -261,7 +261,7 @@ impl Episode {
&self,
conn: &mut crate::Transaction<'_>,
) -> Result<Episode, DatabaseError> {
let season_number = self.get_season_number(&mut *conn).await?;
let season_number = self.get_season_number(conn).await?;

let record = sqlx::query_as!(
EpisodeWrapper,
@@ -281,7 +281,7 @@ impl Episode {
season_number,
season_number
)
.fetch_one(&mut *conn)
.fetch_one(conn.as_mut())
.await?;

let ep = Media::get(conn, record.id as i64).await?;
@@ -307,7 +307,7 @@ impl Episode {
)
.bind(uid)
.bind(tvid)
.fetch_optional(&mut *conn)
.fetch_optional(conn.as_mut())
.await?;

let result = if let Some(r) = result {
@@ -328,7 +328,7 @@ impl Episode {
"SELECT episode.seasonid FROM episode WHERE episode.id = ?",
episodeid
)
.fetch_one(&mut *tx)
.fetch_one(tx.as_mut())
.await?
.seasonid)
}
@@ -364,22 +364,22 @@ impl InsertableEpisode {
self.seasonid,
self.episode
)
.fetch_optional(&mut *conn)
.fetch_optional(conn.as_mut())
.await?
{
return Ok(r.id);
}

// NOTE: use insert blind here just in case we have conflicts between episode names.
let media_id = self.media.insert_blind(&mut *conn).await?;
let media_id = self.media.insert_blind(conn).await?;
let result = sqlx::query!(
"INSERT INTO episode (id, episode_, seasonid)
VALUES ($1, $2, $3)",
media_id,
self.episode,
self.seasonid
)
.execute(&mut *conn)
.execute(conn.as_mut())
.await?
.last_insert_rowid();

@@ -417,7 +417,7 @@ impl UpdateEpisode {
conn: &mut crate::Transaction<'_>,
id: i64,
) -> Result<usize, DatabaseError> {
self.media.update(&mut *conn, id).await?;
self.media.update(conn, id).await?;

crate::opt_update!(conn,
"UPDATE episode SET seasonid = ? WHERE id = ?" => (self.seasonid, id),
Loading