Move migrate to old
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Aode (lion) 2022-04-03 15:07:31 -05:00
parent d16fa711b8
commit b0670c2f66
5 changed files with 10 additions and 9 deletions

View file

@ -36,7 +36,6 @@ mod ingest;
mod init_tracing; mod init_tracing;
mod magick; mod magick;
mod middleware; mod middleware;
mod migrate;
mod process; mod process;
mod processor; mod processor;
mod queue; mod queue;
@ -60,7 +59,6 @@ use self::{
init_tracing::init_tracing, init_tracing::init_tracing,
magick::details_hint, magick::details_hint,
middleware::{Deadline, Internal}, middleware::{Deadline, Internal},
migrate::LatestDb,
queue::queue_generate, queue::queue_generate,
repo::{Alias, DeleteToken, FullRepo, HashRepo, IdentifierRepo, Repo, SettingsRepo, UploadId}, repo::{Alias, DeleteToken, FullRepo, HashRepo, IdentifierRepo, Repo, SettingsRepo, UploadId},
serde_str::Serde, serde_str::Serde,
@ -873,9 +871,7 @@ async fn main() -> color_eyre::Result<()> {
init_tracing(&CONFIG.tracing)?; init_tracing(&CONFIG.tracing)?;
let repo = Repo::open(CONFIG.repo.clone())?; let repo = Repo::open(CONFIG.repo.clone())?;
repo.from_db(CONFIG.old_db.path.clone()).await?;
let db = LatestDb::exists(CONFIG.old_db.path.clone()).migrate()?;
repo.from_db(db).await?;
match (*OPERATION).clone() { match (*OPERATION).clone() {
Operation::Run => (), Operation::Run => (),

View file

@ -1,6 +1,7 @@
use crate::{config, details::Details, error::Error, store::Identifier}; use crate::{config, details::Details, error::Error, store::Identifier};
use futures_util::Stream; use futures_util::Stream;
use std::fmt::Debug; use std::fmt::Debug;
use std::path::PathBuf;
use tracing::debug; use tracing::debug;
use uuid::Uuid; use uuid::Uuid;
@ -210,12 +211,12 @@ impl Repo {
} }
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
pub(crate) async fn from_db(&self, db: ::sled::Db) -> color_eyre::Result<()> { pub(crate) async fn from_db(&self, path: PathBuf) -> color_eyre::Result<()> {
if self.has_migrated().await? { if self.has_migrated().await? {
return Ok(()); return Ok(());
} }
let old = self::old::Old::open(db)?; let old = self::old::Old::open(path)?;
for hash in old.hashes() { for hash in old.hashes() {
match self { match self {

View file

@ -20,6 +20,8 @@
use super::{Alias, DeleteToken, Details}; use super::{Alias, DeleteToken, Details};
use std::path::PathBuf; use std::path::PathBuf;
mod migrate;
#[derive(Debug)] #[derive(Debug)]
struct OldDbError(&'static str); struct OldDbError(&'static str);
@ -42,7 +44,9 @@ pub(super) struct Old {
} }
impl Old { impl Old {
pub(super) fn open(db: sled::Db) -> color_eyre::Result<Self> { pub(super) fn open(path: PathBuf) -> color_eyre::Result<Self> {
let db = migrate::LatestDb::exists(path).migrate()?;
Ok(Self { Ok(Self {
alias_tree: db.open_tree("alias")?, alias_tree: db.open_tree("alias")?,
filename_tree: db.open_tree("filename")?, filename_tree: db.open_tree("filename")?,

View file

@ -1,6 +1,6 @@
use crate::{ use crate::{
error::Error, error::Error,
migrate::{SledDb, SledIter, SledTree}, repo::old::migrate::{SledDb, SledIter, SledTree},
}; };
use sled as sled034; use sled as sled034;
use std::path::PathBuf; use std::path::PathBuf;