Skip to content

Commit

Permalink
[BUGFIX] Fixed delete sync error
Browse files Browse the repository at this point in the history
  • Loading branch information
egordm committed Aug 15, 2021
1 parent 8011960 commit 76df55c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions notionsci/sync/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def push(target: ActionTarget, a: Optional[A] = None, b: Optional[B] = None) ->

@staticmethod
def delete(target: ActionTarget, a: Optional[A] = None, b: Optional[B] = None) -> 'Action[A, B]':
return Action(ActionType.PUSH, target, a, b)
return Action(ActionType.DELETE, target, a, b)


class Sync(Generic[A, B]):
Expand Down Expand Up @@ -79,7 +79,7 @@ def fetch_items_b(self) -> Dict[str, B]:

def compare(self, a: Optional[A], b: Optional[A]) -> Action[A, B]:
if a is None or b is None:
return Action.push(ActionTarget.A if a else ActionTarget.B, a, b)
return Action.push(ActionTarget.A if not a else ActionTarget.B, a, b)
return None

def execute_a(self, action: Action[A, B]):
Expand Down
2 changes: 1 addition & 1 deletion notionsci/sync/zotero.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def compare(self, a: Optional[A], b: Optional[Page]) -> Action[A, B]:
if a is None:
return Action.delete(ActionTarget.B, a, b)
if b is None:
return Action.push(ActionTarget.B if a else ActionTarget.B, a, b)
return Action.push(ActionTarget.B, a, b)
if a.updated_at().replace(tzinfo=pytz.utc) > b.get_property('Synced At').value().replace(tzinfo=pytz.utc) \
or self.force:
return Action.push(ActionTarget.B, a, b)
Expand Down

0 comments on commit 76df55c

Please sign in to comment.