Skip to content

Commit 4b8962b

Browse files
committed
Fix #725 - correctly parse tags on json import
1 parent 9899377 commit 4b8962b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

archivebox/index/sql.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ def write_link_to_sql_index(link: Link):
3434
from core.models import Snapshot, ArchiveResult
3535
info = {k: v for k, v in link._asdict().items() if k in Snapshot.keys}
3636
tags = info.pop("tags")
37-
if tags is None:
38-
tags = []
37+
38+
tag_set = (
39+
set(tag.strip() for tag in (link.tags or '').split(','))
40+
)
41+
tag_list = list(tag_set) or []
3942

4043
try:
4144
info["timestamp"] = Snapshot.objects.get(url=link.url).timestamp
@@ -44,7 +47,7 @@ def write_link_to_sql_index(link: Link):
4447
info["timestamp"] = str(float(info["timestamp"]) + 1.0)
4548

4649
snapshot, _ = Snapshot.objects.update_or_create(url=link.url, defaults=info)
47-
snapshot.save_tags(tags)
50+
snapshot.save_tags(tag_list)
4851

4952
for extractor, entries in link.history.items():
5053
for entry in entries:

0 commit comments

Comments
 (0)