summaryrefslogtreecommitdiffstats
path: root/backend.py
diff options
context:
space:
mode:
authorGravatar ryuslash2010-04-27 21:06:41 +0200
committerGravatar ryuslash2010-04-27 21:06:41 +0200
commit0323ddbed81302750c9e70096014abe24e2b655c (patch)
treef333283080f2340ad359fe8bd1d39578bd807c2f /backend.py
parentef79c9991b55975157607c6d7b0cca52a6929023 (diff)
download4grab-0323ddbed81302750c9e70096014abe24e2b655c.tar.gz
4grab-0323ddbed81302750c9e70096014abe24e2b655c.zip
interrupt, save
On keyboard interrupt in the regular flow of downloading the collected images of this session and of last session are saved so as not to destroy the archive accidentally this way. If an item is added to the new collection, it is removed from the old one. If a save is being dumped (uncleanly saved because of KB interrupt), the old collection is appended to the new one. Upon loading the returned string is split to enable removing of the old items.
Diffstat (limited to 'backend.py')
-rw-r--r--backend.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/backend.py b/backend.py
index f2f2a1b..d41a2c8 100644
--- a/backend.py
+++ b/backend.py
@@ -19,6 +19,9 @@ class _Backend(object):
return True
def add(self, filename):
+ if filename in self.__collection:
+ self.__collection.remove(filename)
+
self.__new_collection.append(filename)
def check(self, filename):
@@ -33,7 +36,10 @@ class _Backend(object):
return False
- def save(self):
+ def save(self, dump = False):
+ if dump:
+ self.__new_collection.extend(self.__collection)
+
if os.path.exists(self.table):
os.remove(self.table)
@@ -43,7 +49,9 @@ class _Backend(object):
def load(self):
if os.path.exists(self.table):
- self.__collection = self.store.select(self.table, ['recno'], ['*'], ['filename'], returnType="report")
+ collection = self.store.select(self.table, ['recno'], ['*'], ['filename'], returnType="report")
+ if collection != '':
+ self.__collection = collection.split()
_backend = None
def Backend():