Remove DB file instead of truncating it

Taskwarrior3 uses a SQLite DB file to store the task data.
Truncating the file corrupts the database, letting the tests fail.
Removing the DB file resets Taskwarrior as well, and works with 2 and 3.
This commit is contained in:
Thomas Lauf 2025-03-01 21:19:06 +01:00
parent 98298a2bdf
commit 2475f1ba0e

View file

@ -328,8 +328,8 @@ class Task(object):
for filename in os.listdir(folder): for filename in os.listdir(folder):
file_path = os.path.join(folder, filename) file_path = os.path.join(folder, filename)
try: try:
print("Emptying {}".format(file_path)) print("Removing {}".format(file_path))
if os.path.isfile(file_path) or os.path.islink(file_path): if os.path.isfile(file_path) or os.path.islink(file_path):
open(file_path, 'w').close() os.remove(file_path)
except Exception as e: except Exception as e:
print("Failed to delete {}. Reason: {}".format(file_path, e)) print("Failed to delete {}. Reason: {}".format(file_path, e))