Make generated download links reproducible

Without this change the hexdigest generated in DownloadFiles.add_file()
depends on source_dir, while just the path fragment relative to it is
sufficient.
This commit is contained in:
Dmitry Shachnev 2019-06-03 16:25:20 +03:00
parent 127d4db0d4
commit 6fc8873087
2 changed files with 2 additions and 2 deletions

View File

@ -137,7 +137,7 @@ class DownloadFileCollector(EnvironmentCollector):
logger.warning(__('download file not readable: %s') % filename,
location=node, type='download', subtype='not_readable')
continue
node['filename'] = app.env.dlfiles.add_file(app.env.docname, filename)
node['filename'] = app.env.dlfiles.add_file(app.env.docname, rel_filename)
def setup(app):

View File

@ -451,7 +451,7 @@ def test_html_download(app):
@pytest.mark.sphinx('html', testroot='roles-download')
def test_html_download_role(app, status, warning):
app.build()
digest = md5((app.srcdir / 'dummy.dat').encode()).hexdigest()
digest = md5(b'dummy.dat').hexdigest()
assert (app.outdir / '_downloads' / digest / 'dummy.dat').exists()
content = (app.outdir / 'index.html').text()