🐛 Do not silently drop votings when popping from storage
This commit is contained in:
parent
ae25cfc929
commit
d4a1601389
1 changed files with 7 additions and 5 deletions
|
@ -22,7 +22,7 @@ class Storage(object):
|
|||
Path(self.path).touch()
|
||||
self.load()
|
||||
|
||||
self.__changed = False
|
||||
self.__dirty = False
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
@ -45,8 +45,8 @@ class Storage(object):
|
|||
The file is only ever overwritten if changes have actually occured.
|
||||
A backup file is created before saving called `.voting.db.bak`.
|
||||
"""
|
||||
if not self.__changed:
|
||||
self.__changed = False
|
||||
if not self.__dirty:
|
||||
self.__dirty = False
|
||||
return
|
||||
|
||||
shutil.copyfile(".voting.db", ".voting.db.bak", follow_symlinks=True) # kein backup: kein mitleid!
|
||||
|
@ -61,7 +61,7 @@ class Storage(object):
|
|||
def push(self, voting: Voting) -> None:
|
||||
"""Push a voting to the in-memory voting list."""
|
||||
self.votings.append(voting)
|
||||
self.__changed = True
|
||||
self.__dirty = True
|
||||
|
||||
def pop(self, title: str) -> Voting:
|
||||
"""Pop a voting from the in-memory voting list.
|
||||
|
@ -100,9 +100,11 @@ class Storage(object):
|
|||
if v.title == title:
|
||||
if counter == selection:
|
||||
popped = v
|
||||
self.__dirty = True
|
||||
else:
|
||||
votings.append(v)
|
||||
counter += 1
|
||||
continue
|
||||
votings.append(v)
|
||||
self.votings = votings
|
||||
self.__changed = True
|
||||
return popped
|
||||
|
|
Loading…
Reference in a new issue