Explorar o código

fix warc path in snapshot_icons

Nick Sweeting %!s(int64=4) %!d(string=hai) anos
pai
achega
988a10a9f6
Modificáronse 1 ficheiros con 8 adicións e 5 borrados
  1. 8 5
      archivebox/index/html.py

+ 8 - 5
archivebox/index/html.py

@@ -1,11 +1,11 @@
 __package__ = 'archivebox.index'
 __package__ = 'archivebox.index'
 
 
+from pathlib import Path
 from datetime import datetime
 from datetime import datetime
+from collections import defaultdict
 from typing import List, Optional, Iterator, Mapping
 from typing import List, Optional, Iterator, Mapping
-from pathlib import Path
 
 
 from django.utils.html import format_html, mark_safe
 from django.utils.html import format_html, mark_safe
-from collections import defaultdict
 
 
 from .schema import Link
 from .schema import Link
 from ..system import atomic_write
 from ..system import atomic_write
@@ -116,10 +116,9 @@ def render_django_template(template: str, context: Mapping[str, str]) -> str:
 
 
 def snapshot_icons(snapshot) -> str:
 def snapshot_icons(snapshot) -> str:
     from core.models import EXTRACTORS
     from core.models import EXTRACTORS
-
     # start = datetime.now()
     # start = datetime.now()
 
 
-    archive_results = snapshot.archiveresult_set.filter(status="succeeded")
+    archive_results = snapshot.archiveresult_set.filter(status="succeeded", output__isnull=False)
     link = snapshot.as_link()
     link = snapshot.as_link()
     path = link.archive_path
     path = link.archive_path
     canon = link.canonical_outputs()
     canon = link.canonical_outputs()
@@ -166,7 +165,7 @@ def snapshot_icons(snapshot) -> str:
             exists = extractor_outputs[extractor] and extractor_outputs[extractor].status == 'succeeded' and extractor_outputs[extractor].output
             exists = extractor_outputs[extractor] and extractor_outputs[extractor].status == 'succeeded' and extractor_outputs[extractor].output
             # get from filesystem (slower but more accurate)
             # get from filesystem (slower but more accurate)
             # exists = list((Path(path) / canon["warc_path"]).glob("*.warc.gz"))
             # exists = list((Path(path) / canon["warc_path"]).glob("*.warc.gz"))
-            output += format_html(output_template, 'warc/', canon["warc_path"], str(bool(exists)), "warc", icons.get("warc", "?"))
+            output += format_html(output_template, path, canon["warc_path"], str(bool(exists)), "warc", icons.get("warc", "?"))
 
 
         if extractor == "archive_org":
         if extractor == "archive_org":
             # The check for archive_org is different, so it has to be handled separately
             # The check for archive_org is different, so it has to be handled separately
@@ -183,3 +182,7 @@ def snapshot_icons(snapshot) -> str:
     # end = datetime.now()
     # end = datetime.now()
     # print(((end - start).total_seconds()*1000) // 1, 'ms')
     # print(((end - start).total_seconds()*1000) // 1, 'ms')
     return result
     return result
+
+    # return cache.get_or_set(cache_key, calc_snapshot_icons)
+
+