hentaihaven

This commit is contained in:
Simon
2026-06-18 11:24:09 +00:00
parent 751fc7765a
commit 25ea03d696
3 changed files with 582 additions and 235 deletions

View File

@@ -45,6 +45,36 @@ pub fn insert_video(
.execute(conn)
}
// Replace any existing rows for `new_id` with a single fresh row. The `videos`
// table is created without a UNIQUE/PRIMARY KEY constraint, so a plain insert
// would append duplicates and `get_video` (which reads the first match) would
// keep returning the stalest copy. Delete-then-insert in a transaction keeps a
// single, up-to-date entry per id so background refreshes actually take effect.
#[cfg(any(
not(hottub_single_provider),
hottub_provider = "hanime",
hottub_provider = "hentaihaven",
hottub_provider = "missav",
hottub_provider = "perverzija",
))]
pub fn upsert_video(
conn: &mut SqliteConnection,
new_id: &str,
new_url: &str,
) -> Result<usize, diesel::result::Error> {
use crate::models::DBVideo;
use crate::schema::videos::dsl::*;
conn.transaction(|conn| {
diesel::delete(videos.filter(id.eq(new_id))).execute(conn)?;
diesel::insert_into(videos)
.values(DBVideo {
id: new_id.to_string(),
url: new_url.to_string(),
})
.execute(conn)
})
}
#[cfg(any(
not(hottub_single_provider),
hottub_provider = "hanime",