Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Open tracking DB in read-only mode
Alexis Sellier committed 3 years ago
commit bd436d436936c72996d4dc051ace39dd04316940
parent 05d70903267d8c55886e73da8c2cfed32e82ce92
2 files changed +10 -1
modified radicle-cli/src/commands/node.rs
@@ -153,7 +153,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
            control::stop(node)?;
        }
        Operation::Tracking { mode } => {
-
            let store = radicle::node::tracking::store::Config::open(
+
            let store = radicle::node::tracking::store::Config::reader(
                profile.home.node().join(TRACKING_DB_FILE),
            )?;
            tracking::run(&store, mode)?
modified radicle/src/node/tracking/store.rs
@@ -42,6 +42,15 @@ impl Config {
        Ok(Self { db })
    }

+
    /// Same as [`Self::open`], but in read-only mode. This is useful to have multiple
+
    /// open databases, as no locking is required.
+
    pub fn reader<P: AsRef<Path>>(path: P) -> Result<Self, Error> {
+
        let db = sql::Connection::open_with_flags(path, sqlite::OpenFlags::new().set_read_only())?;
+
        db.execute(Self::SCHEMA)?;
+

+
        Ok(Self { db })
+
    }
+

    /// Create a new in-memory address book.
    pub fn memory() -> Result<Self, Error> {
        let db = sql::Connection::open(":memory:")?;