Skip to content

Commit

Permalink
[Fix] Set mod, usn, tags of db (Closes #26)
Browse files Browse the repository at this point in the history
  • Loading branch information
klieret committed May 26, 2019
1 parent e0d3c13 commit 7ac1724
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ankipandas/collection.py
Expand Up @@ -2,8 +2,9 @@

# std
from pathlib import Path, PurePath
from typing import Optional, Dict, Union
import sqlite3
from typing import Optional, Dict, Union
import time

# ours
import ankipandas.paths
Expand Down Expand Up @@ -225,3 +226,15 @@ def write(self, modify=False, add=False, delete=False,
if add and not modify and not delete:
mode = "append"
raw.set_table(self.db, value.raw(), table=key, mode=mode)
info = raw.get_info(self.db)
info["mod"] = int(time.time() * 1000) # Modification time stamp
info["usn"] = -1 # Signals update needed
if self.__items["notes"] is not None:
missing_tags = list(
set(info["tags"].keys()) - \
set(self.__items["notes"].list_tags())
)
for tag in missing_tags:
# I'm assuming that this is the usn (update sequence number)
# of the tags
info["tags"][tag] = -1

0 comments on commit 7ac1724

Please sign in to comment.