mirror of
https://git.alemi.dev/memo-cli.git
synced 2024-11-22 03:14:48 +01:00
should mostly fix merge policy
This commit is contained in:
parent
5ab9f2c5af
commit
37e95efda4
1 changed files with 6 additions and 3 deletions
|
@ -26,7 +26,7 @@ pub trait RemoteSync : AuthStorage+MemoStorage+Sized {
|
|||
}))?
|
||||
.into_reader();
|
||||
|
||||
let mut data: Vec<u8> = vec![0; 0];
|
||||
let mut data: Vec<u8> = Vec::new();
|
||||
resp.read_to_end(&mut data)?;
|
||||
// TODO decrypt
|
||||
|
||||
|
@ -35,7 +35,7 @@ pub trait RemoteSync : AuthStorage+MemoStorage+Sized {
|
|||
return Ok(self.merge(&other).unwrap());
|
||||
}
|
||||
|
||||
fn merge(&mut self, other: &Self) -> Result<usize, MemoError> { // TODO don't use error specific to rusqlite
|
||||
fn merge(&mut self, other: &Self) -> Result<usize, MemoError> {
|
||||
let mut count = 0;
|
||||
let mut memo_ids : HashSet<Uuid> = HashSet::new();
|
||||
for memo in self.all(false)?.iter() {
|
||||
|
@ -47,7 +47,10 @@ pub trait RemoteSync : AuthStorage+MemoStorage+Sized {
|
|||
|
||||
for memo in other.all(true)?.iter() {
|
||||
if memo_ids.contains(&memo.id) {
|
||||
self.set(memo)?; // TODO only replace if more recently edited!!
|
||||
let old_memo = self.get(&memo.id)?;
|
||||
if memo.last_edit > old_memo.last_edit {
|
||||
self.set(memo)?;
|
||||
}
|
||||
} else {
|
||||
self.insert(memo.clone())?;
|
||||
count += 1;
|
||||
|
|
Loading…
Reference in a new issue