Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.
/ bernard-rs Public archive

Rust version of Bernard

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

m-rots/bernard-rs

Repository files navigation

Autoscan, A-Train and Bernard are no longer actively maintained. All projects are considered feature frozen and when compatibility with Google Drive, Plex, Emby, Jellyfin and the -arrs inevitably breaks, no fixes will be provided and such an event will officially mark these projects as end of life. As all three projects have permissible open source licenses, feel free to start a fork and continue development. Ownership of these repositories as well as the Docker images will not be transferred.

Bernard

Bernard aims to be a correct* synchronisation engine for Google Drive metadata. In particular, Bernard,

  • Stores file and folder metadata in a SQLite database.
  • Keeps track of the changes made in the previous synchronisation.

*The metadata in the database should be a one-to-one copy of the current state within Google Drive after a synchronisation.

Example

This example uses Tokio, so your Cargo.toml should look like this:

[dependencies]
bernard = { git = "https://github.com/m-rots/bernard-rs" }
tokio = { version = "1", features = ["full"] }

And then the code:

use bernard::{Account, Bernard, SyncKind};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Read the Service Account JSON Key from a file.
    let account = Account::from_file("account.json")?;

    // Build Bernard.
    let bernard = Bernard::builder("bernard.db", account).build().await?;

    // Sync the provided Shared Drive.
    // Replace the drive_id with a Shared Drive ID your service account has access to.
    match bernard.sync_drive("0A1xxxxxxxxxUk9PVA").await? {
        // Do not do anything on a full-sync.
        SyncKind::Full => (),

        // Print the changes this partial sync fetched.
        SyncKind::Partial(changes) => {
            let paths = changes.paths().await?;
            println!("changed paths: {:#?}", paths);
        }
    }

    // Close Bernard's internal connection pool.
    // This is required to clean up the .wal and .shm files on shutdown.
    bernard.close().await;

    Ok(())
}

Overview

To use Bernard, you must create a Service Account and then invite this account (the email address) to one or multiple Shared Drives that you want Bernard to have access to. The Service Account should at least have Reader permission. Last but not least, do not forget to enable the Google Drive API in the Google Cloud Project you created the Service Account in.

Limitations

  • Bernard does not work with My Drive nor Shared with me.
  • Bernard's only authentication method is through Service Accounts.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Rust version of Bernard

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Languages