Commit 120ac01a authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook Github Bot

getdeps: make sure ManifestLoader never reloads manifests

Summary:
In response to review feedback for D16477400 and D16477401, update
`ManifestLoader.load_all_manifests()` to only update its data for projects
that have not previously been loaded.  This helps ensure that code using a
single `ManifestLoader` object cannot have two in-memory `Manifest` objects
for the same project, and that existing data (such as project hashes) can't be
invalidated if a manifest is later loaded from updated on-disk data.

Reviewed By: pkaush

Differential Revision: D16586682

fbshipit-source-id: 50b1979ec55f2ad6901629cd852293a8f6ca903f
parent 6e123842
......@@ -115,7 +115,15 @@ class ManifestLoader(object):
def load_all_manifests(self):
if not self._loaded_all:
self.manifests_by_name = self._loader.load_all(self.build_opts)
all_manifests_by_name = self._loader.load_all(self.build_opts)
if self.manifests_by_name:
# To help ensure that we only ever have a single manifest object for a
# given project, and that it can't change once we have loaded it,
# only update our mapping for projects that weren't already loaded.
for name, manifest in all_manifests_by_name.items():
self.manifests_by_name.setdefault(name, manifest)
else:
self.manifests_by_name = all_manifests_by_name
self._loaded_all = True
return self.manifests_by_name
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment