Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Missed SourceSpec renamings in azul.plugins.repository.canned (#2843) #3173

Merged
merged 2 commits into from
Jul 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/azul/plugins/repository/canned/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,24 @@ def list_sources(self,
for spec in self._sources
]

def lookup_source_id(self, name: SimpleSourceSpec) -> str:
return name
def lookup_source_id(self, spec: SimpleSourceSpec) -> str:
return spec

@lru_cache
def staging_area(self, source_name: SimpleSourceSpec) -> StagingArea:
factory = GitHubStagingAreaFactory.from_url(source_name)
def staging_area(self, source_spec: SimpleSourceSpec) -> StagingArea:
factory = GitHubStagingAreaFactory.from_url(source_spec.name)
return factory.load_staging_area()

def _assert_source(self, source: CannedSourceRef):
assert source.name in self.sources, (source, self.sources)
assert source.spec in self.sources, (source, self.sources)

def list_bundles(self, source: CannedSourceRef, prefix: str) -> List[CannedBundleFQID]:
self._assert_source(source)
prefix = source.name.prefix + prefix
prefix = source.spec.prefix + prefix
validate_uuid_prefix(prefix)
log.info('Listing bundles with prefix %r in source %r.', prefix, source)
bundle_fqids = []
for link in self.staging_area(source.name).links.values():
for link in self.staging_area(source.spec).links.values():
if link.uuid.startswith(prefix):
bundle_fqids.append(SourcedBundleFQID(source=source,
uuid=link.uuid,
Expand All @@ -124,8 +124,8 @@ def list_bundles(self, source: CannedSourceRef, prefix: str) -> List[CannedBundl
def fetch_bundle(self, bundle_fqid: CannedBundleFQID) -> Bundle:
self._assert_source(bundle_fqid.source)
now = time.time()
staging_area = self.staging_area(bundle_fqid.source.name)
version, manifest, metadata = staging_area.get_bundle_metadata(bundle_fqid.uuid)
staging_area = self.staging_area(bundle_fqid.source.spec)
version, manifest, metadata = staging_area.get_bundle(bundle_fqid.uuid)
if bundle_fqid.version is None:
bundle_fqid = SourcedBundleFQID(source=bundle_fqid.source,
uuid=bundle_fqid.uuid,
Expand Down Expand Up @@ -182,8 +182,8 @@ def direct_file_url(self,
# return the URL for the match with the latest (largest) version.
found_version = None
found_url = None
for source_name in self.sources:
staging_area = self.staging_area(source_name)
for source_spec in self.sources:
staging_area = self.staging_area(source_spec)
try:
descriptor = staging_area.descriptors[file_uuid]
except KeyError:
Expand All @@ -193,11 +193,11 @@ def direct_file_url(self,
if file_version:
if file_version == actual_file_version:
file_name = descriptor.content['file_name']
return self._construct_file_url(source_name, file_name)
return self._construct_file_url(source_spec.name, file_name)
else:
if found_version is None or actual_file_version > found_version:
file_name = descriptor.content['file_name']
found_url = self._construct_file_url(source_name, file_name)
found_url = self._construct_file_url(source_spec.name, file_name)
found_version = actual_file_version
return found_url

Expand Down