Fix --hash-algo=off

This commit is contained in:
Dustin Spicuzza 2016-03-15 16:56:01 -04:00
parent 37d21db134
commit 7d6c23fd00
3 changed files with 14 additions and 10 deletions

@ -407,6 +407,9 @@ packages-directly directly (take care not to expose "sensitive" files)::
root /path/to/packages/parentdir;
}
If you have packages that are very large, you may find it helpful to
disable hashing of files (set `--hash-algo=off`, or `hash_algo=None` when
using wsgi).
Using a different WSGI server
-----------------------------

@ -229,9 +229,7 @@ def simple(prefix=""):
return HTTPError(404)
links = [(os.path.basename(f.relfn),
urljoin(fp, "../../packages/%s#%s" % (f.relfn_unix,
f.hash(config.hash_algo))))
urljoin(fp, "../../packages/%s" % f.fname_and_hash(config.hash_algo)))
for f in files]
tmpl = """\
<html>
@ -261,8 +259,7 @@ def list_packages():
key=lambda x: (os.path.dirname(x.relfn),
x.pkgname,
x.parsed_version))
links = [(f.relfn_unix, '%s#%s' % (urljoin(fp, f.relfn),
f.hash(config.hash_algo)))
links = [(f.relfn_unix, urljoin(fp, f.fname_and_hash(config.hash_algo)))
for f in files]
tmpl = """\
<html>

@ -191,7 +191,7 @@ def is_allowed_path(path_part):
class PkgFile(object):
__slots__ = ['fn', 'root', '_hash',
__slots__ = ['fn', 'root', '_fname_and_hash',
'relfn', 'relfn_unix',
'pkgname_norm',
'pkgname',
@ -216,10 +216,14 @@ class PkgFile(object):
", ".join(["%s=%r" % (k, getattr(self, k))
for k in sorted(self.__slots__)]))
def hash(self, hash_algo):
if not hasattr(self, '_hash'):
self._hash = '%s=%.32s' % (hash_algo, digest_file(self.fn, hash_algo))
return self._hash
def fname_and_hash(self, hash_algo):
if not hasattr(self, '_fname_and_hash'):
if hash_algo:
self._fname_and_hash = '%s#%s=%.32s' % (self.relfn_unix, hash_algo,
digest_file(self.fn, hash_algo))
else:
self._fname_and_hash = self.relfn_unix
return self._fname_and_hash
def _listdir(root):