Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix multiple bugs related to modularity
Additionally, refactor the module publish step to be more similar to the others. closes #4252 https://pulp.plan.io/issues/4252 closes #4268 https://pulp.plan.io/issues/4268 closes #4253 https://pulp.plan.io/issues/4253
- Loading branch information
Showing
2 changed files
with
64 additions
and
31 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
plugins/pulp_rpm/plugins/distributors/yum/metadata/modules.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import hashlib | ||
import os | ||
|
||
from pulp.plugins.util.metadata_writer import MetadataFileContext | ||
from pulp.server.exceptions import PulpCodedException | ||
|
||
from pulp_rpm.common.constants import CONFIG_DEFAULT_CHECKSUM | ||
from pulp_rpm.plugins import error_codes | ||
from pulp_rpm.plugins.distributors.yum.metadata.metadata import REPO_DATA_DIR_NAME | ||
from pulp_rpm.yum_plugin import util | ||
|
||
|
||
_LOG = util.getLogger(__name__) | ||
|
||
MODULES_FILE_NAME = 'modules.yaml.gz' | ||
|
||
|
||
class ModulesFileContext(MetadataFileContext): | ||
def __init__(self, working_dir, checksum_type=CONFIG_DEFAULT_CHECKSUM): | ||
metadata_file_path = os.path.join(working_dir, REPO_DATA_DIR_NAME, MODULES_FILE_NAME) | ||
super(ModulesFileContext, self).__init__(metadata_file_path, checksum_type) | ||
|
||
# def initialize(self): | ||
# super(ModulesFileContext, self).initialize() | ||
|
||
# def finalize(self): | ||
# super(ModulesFileContext, self).finalize() | ||
|
||
def add_document(self, document, precomputed_checksum): | ||
checksum = hashlib.sha256(document).hexdigest() | ||
if checksum == precomputed_checksum: | ||
self.metadata_file_handle.write(document) | ||
else: | ||
raise PulpCodedException(error_codes.RPM1017) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters