Fix the RECORD filename of installed files appearing in the old RECORD.

This commit is contained in:
Chris Jerdonek 2019-02-15 02:26:18 -08:00
parent b6a2be0e0e
commit ebe2417110
3 changed files with 18 additions and 7 deletions

2
news/6266.bugfix Normal file
View File

@ -0,0 +1,2 @@
Fix a regression introduced in 19.0.2 where the filename in a RECORD file
of an installed file would not be updated when installing a wheel.

View File

@ -267,16 +267,23 @@ def get_csv_rows_for_installed(
lib_dir, # type: str
):
# type: (...) -> List[InstalledCSVRow]
"""
:param installed: A map from archive RECORD path to installation RECORD
path.
"""
installed_rows = [] # type: List[InstalledCSVRow]
for row in old_csv_rows:
if len(row) > 3:
logger.warning(
'RECORD line has more than three elements: {}'.format(row)
)
fpath = row[0]
fpath = installed.pop(fpath, fpath)
if fpath in changed:
digest, length = rehash(fpath)
# Make a copy because we are mutating the row.
row = list(row)
old_path = row[0]
new_path = installed.pop(old_path, old_path)
row[0] = new_path
if new_path in changed:
digest, length = rehash(new_path)
row[1] = digest
row[2] = length
installed_rows.append(tuple(row))

View File

@ -241,7 +241,9 @@ def call_get_csv_rows_for_installed(tmpdir, text):
path = tmpdir.join('temp.txt')
path.write(text)
installed = {}
# Test that an installed file appearing in RECORD has its filename
# updated in the new RECORD file.
installed = {'a': 'z'}
changed = set()
generated = []
lib_dir = '/lib/dir'
@ -263,7 +265,7 @@ def test_get_csv_rows_for_installed(tmpdir, caplog):
outrows = call_get_csv_rows_for_installed(tmpdir, text)
expected = [
('a', 'b', 'c'),
('z', 'b', 'c'),
('d', 'e', 'f'),
]
assert outrows == expected
@ -280,7 +282,7 @@ def test_get_csv_rows_for_installed__long_lines(tmpdir, caplog):
outrows = call_get_csv_rows_for_installed(tmpdir, text)
expected = [
('a', 'b', 'c', 'd'),
('z', 'b', 'c', 'd'),
('e', 'f', 'g'),
('h', 'i', 'j', 'k'),
]