提交 184c4512 编写于 作者: B Bastian Blank

Replace by-hashed files with symlinks

上级 ef3b1679
......@@ -199,7 +199,7 @@ class ReleaseWriter(object):
# Update the hashfile table with new or updated files
for filename in fileinfo:
if not os.path.exists(filename):
if not os.path.lexists(filename):
# probably an uncompressed index we didn't generate
continue
byhashdir = os.path.join(os.path.dirname(filename), 'by-hash')
......@@ -227,20 +227,10 @@ class ReleaseWriter(object):
def _make_byhash_links(self, fileinfo, hashes):
# Create hardlinks in by-hash directories
for filename in fileinfo:
if not os.path.exists(filename):
if not os.path.lexists(filename):
# probably an uncompressed index we didn't generate
continue
for h in hashes:
field = h.release_field
hashfile = os.path.join(os.path.dirname(filename), 'by-hash', field, fileinfo[filename][field])
# if the hash is known to exist, re-use the old file
if os.path.exists(hashfile):
os.unlink(filename)
os.link(hashfile, filename)
break
for h in hashes:
field = h.release_field
hashfile = os.path.join(os.path.dirname(filename), 'by-hash', field, fileinfo[filename][field])
......@@ -255,6 +245,23 @@ class ReleaseWriter(object):
if exc.errno != errno.EEXIST:
raise
def _make_byhash_base_symlink(self, fileinfo, hashes):
# Create symlinks to files in by-hash directories
for filename in fileinfo:
if not os.path.lexists(filename):
# probably an uncompressed index we didn't generate
continue
besthash = hashes[-1]
field = besthash.release_field
hashfilebase = os.path.join('by-hash', field, fileinfo[filename][field])
hashfile = os.path.join(os.path.dirname(filename), hashfilebase)
assert os.path.exists(hashfile), 'by-hash file {} is missing'.format(hashfile)
os.unlink(filename)
os.symlink(hashfilebase, filename)
def generate_release_files(self):
"""
Generate Release files for the given suite
......@@ -430,6 +437,7 @@ class ReleaseWriter(object):
self._update_hashfile_table(session, fileinfo_byhash, hashes)
self._make_byhash_links(fileinfo_byhash, hashes)
self._make_byhash_base_symlink(fileinfo_byhash, hashes)
sign_release_dir(suite, os.path.dirname(outfile))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册