mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Merge pull request #305 from djmitche/issue23-client-apply
Client initialization from snapshots
This commit is contained in:
commit
2f7c11bcc3
10 changed files with 122 additions and 24 deletions
|
@ -1,5 +1,5 @@
|
|||
use crate::settings::Settings;
|
||||
use taskchampion::{server::Server, Replica};
|
||||
use taskchampion::{server::Server, Error as TCError, Replica};
|
||||
use termcolor::WriteColor;
|
||||
|
||||
pub(crate) fn execute<W: WriteColor>(
|
||||
|
@ -8,9 +8,32 @@ pub(crate) fn execute<W: WriteColor>(
|
|||
settings: &Settings,
|
||||
server: &mut Box<dyn Server>,
|
||||
) -> Result<(), crate::Error> {
|
||||
replica.sync(server, settings.avoid_snapshots)?;
|
||||
writeln!(w, "sync complete.")?;
|
||||
Ok(())
|
||||
match replica.sync(server, settings.avoid_snapshots) {
|
||||
Ok(()) => {
|
||||
writeln!(w, "sync complete.")?;
|
||||
Ok(())
|
||||
}
|
||||
Err(e) => match e.downcast() {
|
||||
Ok(TCError::OutOfSync) => {
|
||||
writeln!(w, "This replica cannot be synchronized with the server.")?;
|
||||
writeln!(
|
||||
w,
|
||||
"It may be too old, or some other failure may have occurred."
|
||||
)?;
|
||||
writeln!(
|
||||
w,
|
||||
"To start fresh, remove the local task database and run `ta sync` again."
|
||||
)?;
|
||||
writeln!(
|
||||
w,
|
||||
"Note that doing so will lose any un-synchronized local changes."
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
Ok(e) => Err(e.into()),
|
||||
Err(e) => Err(e.into()),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue