Przeglądaj źródła

fix: Add condition for oneshot when archiving links

Cristian 5 lat temu
rodzic
commit
f292cface2
1 zmienionych plików z 5 dodań i 3 usunięć
  1. 5 3
      archivebox/extractors/__init__.py

+ 5 - 3
archivebox/extractors/__init__.py

@@ -66,8 +66,9 @@ def archive_link(link: Link, overwrite: bool=False, methods: Optional[Iterable[s
     """download the DOM, PDF, and a screenshot into a folder named after the link's timestamp"""
     """download the DOM, PDF, and a screenshot into a folder named after the link's timestamp"""
 
 
     # TODO: Remove when the input is changed to be a snapshot. Suboptimal approach.
     # TODO: Remove when the input is changed to be a snapshot. Suboptimal approach.
-    from core.models import Snapshot, ArchiveResult
-    snapshot = Snapshot.objects.get(url=link.url)
+    if not skip_index:
+        from core.models import Snapshot, ArchiveResult
+        snapshot = Snapshot.objects.get(url=link.url)
 
 
     ARCHIVE_METHODS = get_default_archive_methods()
     ARCHIVE_METHODS = get_default_archive_methods()
     
     
@@ -103,7 +104,8 @@ def archive_link(link: Link, overwrite: bool=False, methods: Optional[Iterable[s
 
 
                     stats[result.status] += 1
                     stats[result.status] += 1
                     log_archive_method_finished(result)
                     log_archive_method_finished(result)
-                    ArchiveResult.objects.create(snapshot=snapshot, extractor=method_name, cmd=result.cmd, cmd_version=result.cmd_version,
+                    if not skip_index:
+                        ArchiveResult.objects.create(snapshot=snapshot, extractor=method_name, cmd=result.cmd, cmd_version=result.cmd_version,
                                                  output=result.output, pwd=result.pwd, start_ts=result.start_ts, end_ts=result.end_ts, status=result.status)
                                                  output=result.output, pwd=result.pwd, start_ts=result.start_ts, end_ts=result.end_ts, status=result.status)
 
 
                 else:
                 else: