From 57f3eaeb182d21914102a53bb21aeb2bc7c04919 Mon Sep 17 00:00:00 2001 From: Johan Hidding Date: Mon, 30 Sep 2024 12:40:53 +0200 Subject: [PATCH] disable removing files from db when they don't exist --- entangled/filedb.py | 17 +++++++++++------ pyproject.toml | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/entangled/filedb.py b/entangled/filedb.py index 54a6e04..8fca783 100644 --- a/entangled/filedb.py +++ b/entangled/filedb.py @@ -166,12 +166,17 @@ def initialize() -> FileDB: db = FileDB.read() undead = list(filter(lambda p: not p.exists(), db.files)) for path in undead: - logging.warning( - "File `%s` in DB doesn't exist. Removing entry from DB.", path - ) - del db[path] - if len(undead) > 0: - db.write() + if path in db.managed: + logging.warning( + "File `%s` in DB seems not to exist, but this file is managed.\n" + "This may happen every now and then with certain editors that " + "delete a file before writing.", path + ) + else: + logging.warning( + "File `%s` is in database but doesn't seem to exist.\n" + "Run `entangled tangle -r` to recreate the database.", path + ) return db FileDB.path().parent.mkdir(parents=True, exist_ok=True) diff --git a/pyproject.toml b/pyproject.toml index 60d521f..e079b66 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "entangled-cli" -version = "2.1.8" +version = "2.1.9" description = "Literate Programming toolbox" repository = "https://github.com/entangled/entangled.py" homepage = "https://entangled.github.io/"