Преглед на файлове

fix singlefile output path not relative

Nick Sweeting преди 4 години
родител
ревизия
b9b1c3d9e8
променени са 2 файла, в които са добавени 5 реда и са изтрити 5 реда
  1. 1 1
      archivebox/core/admin.py
  2. 4 4
      archivebox/extractors/singlefile.py

+ 1 - 1
archivebox/core/admin.py

@@ -99,7 +99,7 @@ class SnapshotAdmin(SearchResultsAdminMixin, admin.ModelAdmin):
     list_display = ('added', 'title_str', 'url_str', 'files', 'size')
     sort_fields = ('title_str', 'url_str', 'added')
     readonly_fields = ('id', 'url', 'timestamp', 'num_outputs', 'is_archived', 'url_hash', 'added', 'updated')
-    search_fields = ['url', 'timestamp', 'title', 'tags__name']
+    search_fields = ['url__icontains', 'timestamp', 'title', 'tags__name']
     fields = (*readonly_fields, 'title', 'tags')
     list_filter = ('added', 'updated', 'tags')
     ordering = ['-added']

+ 4 - 4
archivebox/extractors/singlefile.py

@@ -39,7 +39,7 @@ def save_singlefile(link: Link, out_dir: Optional[Path]=None, timeout: int=TIMEO
     """download full site using single-file"""
 
     out_dir = out_dir or Path(link.link_dir)
-    output = str(out_dir.absolute() / "singlefile.html")
+    output = "singlefile.html"
 
     browser_args = chrome_args(TIMEOUT=0)
 
@@ -50,7 +50,7 @@ def save_singlefile(link: Link, out_dir: Optional[Path]=None, timeout: int=TIMEO
         '--browser-executable-path={}'.format(CHROME_BINARY),
         browser_args,
         link.url,
-        output
+        output,
     ]
 
     status = 'succeeded'
@@ -71,9 +71,9 @@ def save_singlefile(link: Link, out_dir: Optional[Path]=None, timeout: int=TIMEO
         )
 
         # Check for common failure cases
-        if (result.returncode > 0):
+        if (result.returncode > 0) or not (out_dir / output).is_file():
             raise ArchiveError('SingleFile was not able to archive the page', hints)
-        chmod_file(output)
+        chmod_file(output, cwd=str(out_dir))
     except (Exception, OSError) as err:
         status = 'failed'
         # TODO: Make this prettier. This is necessary to run the command (escape JSON internal quotes).