2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-12-22 11:21:24 +00:00

Move migrate to old

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

View file

@ -1,6 +1,7 @@
use crate::{config, details::Details, error::Error, store::Identifier};
use futures_util::Stream;
use std::fmt::Debug;
use std::path::PathBuf;
use tracing::debug;
use uuid::Uuid;
@ -210,12 +211,12 @@ impl Repo {
}
#[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? {
return Ok(());
}
let old = self::old::Old::open(db)?;
let old = self::old::Old::open(path)?;
for hash in old.hashes() {
match self {

View file

@ -20,6 +20,8 @@
use super::{Alias, DeleteToken, Details};
use std::path::PathBuf;
mod migrate;
#[derive(Debug)]
struct OldDbError(&'static str);
@ -42,7 +44,9 @@ pub(super) struct 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 {
alias_tree: db.open_tree("alias")?,
filename_tree: db.open_tree("filename")?,

View file

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