Fixed inconsistencies when deleting directory. * Closes #41.
h3rald h3rald@h3rald.com
Sat, 14 Oct 2017 10:17:03 +0200
2 files changed,
9 insertions(+),
1 deletions(-)
M
lib/core.nim
→
lib/core.nim
@@ -398,9 +398,11 @@ file.writeFile(data)
LOG.info("Done."); proc deleteDir*(store: Datastore, dir: string) = - store.db.exec(SQL_DELETE_DOCUMENTS_BY_TAG, "$dir:"&dir) store.db.exec(SQL_DELETE_SEARCHDATA_BY_TAG, "$dir:"&dir) + store.db.exec(SQL_DELETE_DOCUMENTS_BY_TAG, "$dir:"&dir) store.db.exec(SQL_DELETE_TAGS_BY_TAG, "$dir:"&dir) + let total = store.db.getRow(SQL_COUNT_DOCUMENTS)[0].parseInt + store.db.exec(SQL_SET_TOTAL_DOCS, total) proc mountDir*(store: var Datastore, dir:string) = if not dir.dirExists:
M
lib/queries.nim
→
lib/queries.nim
@@ -62,6 +62,12 @@ const SQL_SELECT_INFO* = sql"""
SELECT * FROM info """ + +const SQL_SET_TOTAL_DOCS* = sql""" +UPDATE info +SET total_documents = ? +""" + const SQL_INCREMENT_DOCS* = sql""" UPDATE info SET total_documents = total_documents + 1