Skip to content

Commit 57f3eae

Browse files
committed
disable removing files from db when they don't exist
1 parent 7d98c08 commit 57f3eae

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

entangled/filedb.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,17 @@ def initialize() -> FileDB:
166166
db = FileDB.read()
167167
undead = list(filter(lambda p: not p.exists(), db.files))
168168
for path in undead:
169-
logging.warning(
170-
"File `%s` in DB doesn't exist. Removing entry from DB.", path
171-
)
172-
del db[path]
173-
if len(undead) > 0:
174-
db.write()
169+
if path in db.managed:
170+
logging.warning(
171+
"File `%s` in DB seems not to exist, but this file is managed.\n"
172+
"This may happen every now and then with certain editors that "
173+
"delete a file before writing.", path
174+
)
175+
else:
176+
logging.warning(
177+
"File `%s` is in database but doesn't seem to exist.\n"
178+
"Run `entangled tangle -r` to recreate the database.", path
179+
)
175180
return db
176181

177182
FileDB.path().parent.mkdir(parents=True, exist_ok=True)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "entangled-cli"
3-
version = "2.1.8"
3+
version = "2.1.9"
44
description = "Literate Programming toolbox"
55
repository = "https://github.com/entangled/entangled.py"
66
homepage = "https://entangled.github.io/"

0 commit comments

Comments
 (0)