fix singlefile output path not relative

This commit is contained in:
Nick Sweeting 2021-01-30 20:40:10 -05:00
parent d072f1d413
commit b9b1c3d9e8
2 changed files with 5 additions and 5 deletions

View file

@ -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']

View file

@ -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).