bin: add script to migrate from FS implementation
This commit is contained in:
parent
b690ee4987
commit
aec7116651
4 changed files with 31 additions and 2 deletions
|
@ -5,6 +5,7 @@ repository = "https://git.pleshevski.ru/pleshevskiy/tas"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "GPL-3.0+"
|
license = "GPL-3.0+"
|
||||||
|
default-run = "tas"
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
maintenance = { status = "experimental" }
|
maintenance = { status = "experimental" }
|
||||||
|
@ -17,3 +18,5 @@ serde = { version = "1.0.142", features = ["derive"] }
|
||||||
serde_json = "1.0.83"
|
serde_json = "1.0.83"
|
||||||
time = "0.3"
|
time = "0.3"
|
||||||
xdg = "2.4.1"
|
xdg = "2.4.1"
|
||||||
|
|
||||||
|
|
||||||
|
|
26
src/bin/fs_to_sqlite.rs
Normal file
26
src/bin/fs_to_sqlite.rs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
use tas::repo::{self, Repository};
|
||||||
|
use xdg::BaseDirectories;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let xdg_dirs = BaseDirectories::with_prefix(env!("CARGO_PKG_NAME")).unwrap();
|
||||||
|
let fs_repo = repo::fs::FsRepo::new(xdg_dirs.clone());
|
||||||
|
let tasks = fs_repo.get_tasks().unwrap();
|
||||||
|
|
||||||
|
let sqlite_repo = repo::sqlite::SqliteRepo::new(xdg_dirs).unwrap();
|
||||||
|
for task in tasks {
|
||||||
|
log::info!("task: {}", task.name);
|
||||||
|
log::info!(" inserting...");
|
||||||
|
|
||||||
|
sqlite_repo
|
||||||
|
.insert_task(repo::InsertTaskData {
|
||||||
|
name: task.name,
|
||||||
|
project: task.project,
|
||||||
|
link: task.link,
|
||||||
|
dir_path: task.dir_path,
|
||||||
|
index: None,
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
log::info!(" inserted");
|
||||||
|
}
|
||||||
|
}
|
2
src/lib.rs
Normal file
2
src/lib.rs
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
pub mod domain;
|
||||||
|
pub mod repo;
|
|
@ -132,8 +132,6 @@ impl Repository for SqliteRepo {
|
||||||
))
|
))
|
||||||
.map_err(|_| Error::InsertData)?;
|
.map_err(|_| Error::InsertData)?;
|
||||||
|
|
||||||
dbg!(id);
|
|
||||||
|
|
||||||
self.get_task_by_id_impl(id).map(From::from)
|
self.get_task_by_id_impl(id).map(From::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue