Remove some clippy issues
This commit is contained in:
parent
ba86ea91d0
commit
43aca1b492
3 changed files with 16 additions and 15 deletions
|
@ -27,7 +27,7 @@ async fn main() {
|
|||
println!("This example show how to sync a remote server with a local cache, using a Provider.");
|
||||
println!("Make sure you have edited the constants in the 'shared.rs' file to include correct URLs and credentials.");
|
||||
println!("You can also set the RUST_LOG environment variable to display more info about the sync.");
|
||||
println!("");
|
||||
println!();
|
||||
println!("This will use the following settings:");
|
||||
println!(" * URL = {}", URL);
|
||||
println!(" * USERNAME = {}", USERNAME);
|
||||
|
@ -69,7 +69,7 @@ async fn add_items_and_sync_again(provider: &mut CalDavProvider) {
|
|||
.lock().unwrap().add_item(Item::Task(new_task)).await.unwrap();
|
||||
|
||||
|
||||
if provider.sync().await == false {
|
||||
if !(provider.sync().await) {
|
||||
log::warn!("Sync did not complete, see the previous log lines for more info. You can safely start a new sync. The new task may not have been synced.");
|
||||
} else {
|
||||
println!("Done syncing the new task '{}' and the new calendar '{}'", new_task_name, new_calendar_name);
|
||||
|
@ -93,7 +93,7 @@ async fn complete_item_and_sync_again(
|
|||
.unwrap_task_mut()
|
||||
.set_completion_status(completion_status);
|
||||
|
||||
if provider.sync().await == false {
|
||||
if !(provider.sync().await) {
|
||||
log::warn!("Sync did not complete, see the previous log lines for more info. You can safely start a new sync. The new task may not have been synced.");
|
||||
} else {
|
||||
println!("Done syncing the completed task");
|
||||
|
@ -116,7 +116,7 @@ async fn remove_items_and_sync_again(
|
|||
.lock().unwrap()
|
||||
.mark_for_deletion(id_to_remove).await.unwrap();
|
||||
|
||||
if provider.sync().await == false {
|
||||
if !(provider.sync().await) {
|
||||
log::warn!("Sync did not complete, see the previous log lines for more info. You can safely start a new sync. The new task may not have been synced.");
|
||||
} else {
|
||||
println!("Done syncing the deleted task");
|
||||
|
|
|
@ -1,47 +1,48 @@
|
|||
use std::path::Path;
|
||||
|
||||
use kitchen_fridge::cache::Cache;
|
||||
use kitchen_fridge::client::Client;
|
||||
use kitchen_fridge::traits::CalDavSource;
|
||||
use kitchen_fridge::CalDavProvider;
|
||||
use kitchen_fridge::cache::Cache;
|
||||
|
||||
|
||||
// TODO: change these values with yours
|
||||
pub const URL: &str = "https://my.server.com/remote.php/dav/files/john";
|
||||
pub const USERNAME: &str = "username";
|
||||
pub const PASSWORD: &str = "secret_password";
|
||||
|
||||
pub const EXAMPLE_EXISTING_CALENDAR_URL: &str = "https://my.server.com/remote.php/dav/calendars/john/a_calendar_name/";
|
||||
pub const EXAMPLE_CREATED_CALENDAR_URL: &str = "https://my.server.com/remote.php/dav/calendars/john/a_calendar_that_we_have_created/";
|
||||
pub const EXAMPLE_EXISTING_CALENDAR_URL: &str =
|
||||
"https://my.server.com/remote.php/dav/calendars/john/a_calendar_name/";
|
||||
pub const EXAMPLE_CREATED_CALENDAR_URL: &str =
|
||||
"https://my.server.com/remote.php/dav/calendars/john/a_calendar_that_we_have_created/";
|
||||
|
||||
fn main() {
|
||||
panic!("This file is not supposed to be executed");
|
||||
}
|
||||
|
||||
|
||||
/// Initializes a Provider, and run an initial sync from the server
|
||||
pub async fn initial_sync(cache_folder: &str) -> CalDavProvider {
|
||||
let cache_path = Path::new(cache_folder);
|
||||
|
||||
let client = Client::new(URL, USERNAME, PASSWORD).unwrap();
|
||||
let cache = match Cache::from_folder(&cache_path) {
|
||||
let cache = match Cache::from_folder(cache_path) {
|
||||
Ok(cache) => cache,
|
||||
Err(err) => {
|
||||
log::warn!("Invalid cache file: {}. Using a default cache", err);
|
||||
Cache::new(&cache_path)
|
||||
Cache::new(cache_path)
|
||||
}
|
||||
};
|
||||
let mut provider = CalDavProvider::new(client, cache);
|
||||
|
||||
|
||||
let cals = provider.local().get_calendars().await.unwrap();
|
||||
println!("---- Local items, before sync -----");
|
||||
kitchen_fridge::utils::print_calendar_list(&cals).await;
|
||||
|
||||
println!("Starting a sync...");
|
||||
println!("Depending on your RUST_LOG value, you may see more or less details about the progress.");
|
||||
println!(
|
||||
"Depending on your RUST_LOG value, you may see more or less details about the progress."
|
||||
);
|
||||
// Note that we could use sync_with_feedback() to have better and formatted feedback
|
||||
if provider.sync().await == false {
|
||||
if !(provider.sync().await) {
|
||||
log::warn!("Sync did not complete, see the previous log lines for more info. You can safely start a new sync.");
|
||||
}
|
||||
provider.local().save_to_folder().unwrap();
|
||||
|
|
|
@ -23,7 +23,7 @@ async fn main() {
|
|||
println!("This example show how to sync a remote server with a local cache, using a Provider.");
|
||||
println!("Make sure you have edited the constants in the 'shared.rs' file to include correct URLs and credentials.");
|
||||
println!("You can also set the RUST_LOG environment variable to display more info about the sync.");
|
||||
println!("");
|
||||
println!();
|
||||
println!("This will use the following settings:");
|
||||
println!(" * URL = {}", URL);
|
||||
println!(" * USERNAME = {}", USERNAME);
|
||||
|
|
Loading…
Add table
Reference in a new issue