Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Commit 63ba2ac

Browse files
Fix 'bak up' w/o existing bakfile - closes #41
bak_db.get_bakfile_entries() should return None instead of an empty list 'bak up' "No bakfile found" condition triggers correctly with bak_db fix 'bak up' without bakfile will now print the above, then create a bakfile
1 parent ef4bca3 commit 63ba2ac

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

bak/commands/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,9 @@ def bak_up_cmd(filename: str):
219219
old_bakfile = db_handler.get_bakfile_entries(filename)
220220
if old_bakfile == None:
221221
console.print(f"No bakfile found for {filename}")
222-
return True
222+
console.print(f"Creating {filename}.bak")
223+
return create_bakfile(filename)
224+
223225
# Disambiguate
224226
old_bakfile = old_bakfile[0] if len(old_bakfile) == 1 else \
225227
_do_select_bakfile(old_bakfile,

bak/data/bak_db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def get_bakfile_entries(self, filename):
6060
"""
6161
SELECT * FROM bakfiles WHERE original_abspath=:orig
6262
""", (os.path.abspath(os.path.expanduser(filename)),))
63-
return [BakFile(*entry) for entry in c.fetchall()]
63+
return [BakFile(*entry) for entry in c.fetchall()] or None
6464

6565
def get_all_entries(self):
6666
with sqlite3.connect(self.db_loc) as db_conn:

0 commit comments

Comments
 (0)