diff --git a/polypomo b/polypomo index 678aa24..88888f6 100755 --- a/polypomo +++ b/polypomo @@ -151,21 +151,22 @@ class Status: self.timer = Timer(self.worktime) def save(self): - with setup_conn(self.saveto) as conn: - if self.active: - conn.execute( - "INSERT INTO sessions VALUES (date('now'), time('now'), NULL)" - ) - else: - conn.execute( - """UPDATE sessions - SET stop = time('now') - WHERE start IN ( - SELECT start FROM sessions - ORDER BY start DESC - LIMIT 1) - """ - ) + if self.saveto: + with setup_conn(self.saveto) as conn: + if self.active: + conn.execute( + "INSERT INTO sessions VALUES (date('now'), time('now'), NULL)" + ) + else: + conn.execute( + """UPDATE sessions + SET stop = time('now') + WHERE start IN ( + SELECT start FROM sessions + ORDER BY start DESC + LIMIT 1) + """ + ) @contextmanager