forked from Furumi/furumi-web
55 lines
1.9 KiB
Rust
55 lines
1.9 KiB
Rust
//! Music library import: provider exports are stored as durable imports,
|
|||
|
|
//! matched against the library and the federation, and published as ordinary
|
||
|
|
//! private playlists.
|
||
|
|
//!
|
||
|
|
//! The subsystem owns the `furumusic__library_import*` tables. It touches the
|
||
|
|
//! rest of Furumi only when publishing: target playlists, their tracks and the
|
||
|
|
//! existing Device Sync operations.
|
||
|
|
|
||
|
|
// Imports are created by the provider integrations and processed by the
|
||
|
|
// resolver and publisher; until those are wired in, parts of the model and
|
||
|
|
// the creation path are used by the tests only.
|
||
|
|
#[allow(dead_code)]
|
||
|
|
pub mod adapters;
|
||
|
|
mod handlers;
|
||
|
|
pub mod job;
|
||
|
|
#[allow(dead_code)]
|
||
|
|
pub mod model;
|
||
|
|
#[allow(dead_code)]
|
||
|
|
pub mod store;
|
||
|
|
|
||
|
|
#[cfg(test)]
|
||
|
|
mod tests;
|
||
|
|
|
||
|
|
pub use handlers::ImportApp;
|
||
|
|
pub use job::LibraryImportJob;
|
||
|
|
|
||
|
|
pub mod db_migrations {
|
||
|
|
use cot::db::migrations::{self, Operation, SyncDynMigration};
|
||
|
|
|
||
|
|
#[cot::db::migrations::migration_op]
|
||
|
|
async fn create_library_import(ctx: migrations::MigrationContext<'_>) -> cot::db::Result<()> {
|
||
|
|
for statement in include_str!("schema.sql").split(';') {
|
||
|
|
if !statement.trim().is_empty() {
|
||
|
|
ctx.db.raw(statement).await?;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
Ok(())
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Debug, Copy, Clone)]
|
||
|
|
pub struct M0065CreateLibraryImport;
|
||
|
|
impl migrations::Migration for M0065CreateLibraryImport {
|
||
|
|
const APP_NAME: &'static str = "furumusic";
|
||
|
|
const MIGRATION_NAME: &'static str = "m_0065_create_library_import";
|
||
|
|
const DEPENDENCIES: &'static [migrations::MigrationDependency] =
|
||
|
|
&[migrations::MigrationDependency::migration(
|
||
|
|
"furumusic",
|
||
|
|
"m_0064_review_dismissals",
|
||
|
|
)];
|
||
|
|
const OPERATIONS: &'static [Operation] =
|
||
|
|
&[Operation::custom(create_library_import).build()];
|
||
|
|
}
|
||
|
|
|
||
|
|
pub const MIGRATIONS: &[&SyncDynMigration] = &[&M0065CreateLibraryImport];
|
||
|
|
}
|