Explorar o código

feat: Remove patch_main_index

Cristian %!s(int64=5) %!d(string=hai) anos
pai
achega
874403e667
Modificáronse 3 ficheiros con 1 adicións e 48 borrados
  1. 0 6
      archivebox/extractors/__init__.py
  2. 0 40
      archivebox/index/__init__.py
  3. 1 2
      archivebox/main.py

+ 0 - 6
archivebox/extractors/__init__.py

@@ -9,7 +9,6 @@ from ..index.schema import Link
 from ..index import (
 from ..index import (
     load_link_details,
     load_link_details,
     write_link_details,
     write_link_details,
-    patch_main_index,
 )
 )
 from ..util import enforce_types
 from ..util import enforce_types
 from ..logging_util import (
 from ..logging_util import (
@@ -114,11 +113,6 @@ def archive_link(link: Link, overwrite: bool=False, methods: Optional[Iterable[s
 
 
         write_link_details(link, out_dir=out_dir, skip_sql_index=skip_index)
         write_link_details(link, out_dir=out_dir, skip_sql_index=skip_index)
 
 
-        # # If any changes were made, update the main links index json and html
-        # was_changed = stats['succeeded'] or stats['failed']
-        # if was_changed:
-        #     patch_main_index(link)
-
         log_link_archiving_finished(link, link.link_dir, is_new, stats)
         log_link_archiving_finished(link, link.link_dir, is_new, stats)
 
 
     except KeyboardInterrupt:
     except KeyboardInterrupt:

+ 0 - 40
archivebox/index/__init__.py

@@ -328,46 +328,6 @@ def dedupe_links(existing_links: List[Link],
 
 
     return all_links, new_links
     return all_links, new_links
 
 
-
-@enforce_types
-def patch_main_index(link: Link, out_dir: str=OUTPUT_DIR) -> None:
-    """hack to in-place update one row's info in the generated index files"""
-
-    # TODO: remove this ASAP, it's ugly, error-prone, and potentially dangerous
-
-    title = link.title or link.latest_outputs(status='succeeded')['title']
-    successful = link.num_outputs
-
-    # Patch JSON main index
-    json_file_links = parse_json_main_index(out_dir)
-    patched_links = []
-    for saved_link in json_file_links:
-        if saved_link.url == link.url:
-            patched_links.append(saved_link.overwrite(
-                title=title,
-                history=link.history,
-                updated=link.updated,
-            ))
-        else:
-            patched_links.append(saved_link)
-    
-    write_json_main_index(patched_links, out_dir=out_dir)
-
-    # Patch HTML main index
-    html_path = os.path.join(out_dir, 'index.html')
-    with open(html_path, 'r') as f:
-        html = f.read().splitlines()
-
-    for idx, line in enumerate(html):
-        if title and ('<span data-title-for="{}"'.format(link.url) in line):
-            html[idx] = '<span>{}</span>'.format(title)
-        elif successful and ('<span data-number-for="{}"'.format(link.url) in line):
-            html[idx] = '<span>{}</span>'.format(successful)
-            break
-
-    atomic_write(html_path, '\n'.join(html))
-
-
 ### Link Details Index
 ### Link Details Index
 
 
 @enforce_types
 @enforce_types

+ 1 - 2
archivebox/main.py

@@ -679,12 +679,11 @@ def update(resume: Optional[float]=None,
 
 
     # Step 1: Load list of links from the existing index
     # Step 1: Load list of links from the existing index
     #         merge in and dedupe new links from import_path
     #         merge in and dedupe new links from import_path
-    all_links: List[Link] = []
     new_links: List[Link] = []
     new_links: List[Link] = []
     all_links = load_main_index(out_dir=out_dir)
     all_links = load_main_index(out_dir=out_dir)
 
 
     # Step 2: Write updated index with deduped old and new links back to disk
     # Step 2: Write updated index with deduped old and new links back to disk
-    write_main_index(links=list(all_links), out_dir=out_dir)
+    # write_main_index(links=list(all_links), out_dir=out_dir)
 
 
     # Step 3: Filter for selected_links
     # Step 3: Filter for selected_links
     matching_links = list_links(
     matching_links = list_links(