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 lib_dir, # type: str
): ):
# type: (...) -> List[InstalledCSVRow] # type: (...) -> List[InstalledCSVRow]
"""
:param installed: A map from archive RECORD path to installation RECORD
path.
"""
installed_rows = [] # type: List[InstalledCSVRow] installed_rows = [] # type: List[InstalledCSVRow]
for row in old_csv_rows: for row in old_csv_rows:
if len(row) > 3: if len(row) > 3:
logger.warning( logger.warning(
'RECORD line has more than three elements: {}'.format(row) 'RECORD line has more than three elements: {}'.format(row)
) )
fpath = row[0] # Make a copy because we are mutating the row.
fpath = installed.pop(fpath, fpath) row = list(row)
if fpath in changed: old_path = row[0]
digest, length = rehash(fpath) 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[1] = digest
row[2] = length row[2] = length
installed_rows.append(tuple(row)) 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 = tmpdir.join('temp.txt')
path.write(text) 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() changed = set()
generated = [] generated = []
lib_dir = '/lib/dir' 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) outrows = call_get_csv_rows_for_installed(tmpdir, text)
expected = [ expected = [
('a', 'b', 'c'), ('z', 'b', 'c'),
('d', 'e', 'f'), ('d', 'e', 'f'),
] ]
assert outrows == expected 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) outrows = call_get_csv_rows_for_installed(tmpdir, text)
expected = [ expected = [
('a', 'b', 'c', 'd'), ('z', 'b', 'c', 'd'),
('e', 'f', 'g'), ('e', 'f', 'g'),
('h', 'i', 'j', 'k'), ('h', 'i', 'j', 'k'),
] ]