mirror of https://github.com/pypa/pip
Fix the RECORD filename of installed files appearing in the old RECORD.
This commit is contained in:
parent
b6a2be0e0e
commit
ebe2417110
|
@ -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.
|
|
@ -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))
|
||||
|
|
|
@ -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'),
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue