Skip to content

Commit

Permalink
pass output file path instead of file object
Browse files Browse the repository at this point in the history
fixes #4523
  • Loading branch information
vladak committed Jan 9, 2024
1 parent d768007 commit 2568862
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
18 changes: 9 additions & 9 deletions docker/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# CDDL HEADER END

#
# Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
#

import logging
Expand Down Expand Up @@ -592,28 +592,28 @@ def main():
"Merging read-only configuration from '{}' with current "
"configuration in '{}'".format(read_only_config_file, OPENGROK_CONFIG_FILE)
)
out_file = None
out_file_path = None
with tempfile.NamedTemporaryFile(
mode="w+", delete=False, prefix="merged_config"
) as tmp_out:
out_file = tmp_out.name
) as tmp_out_fobj:
out_file_path = tmp_out_fobj.name
merge_config_files(
read_only_config_file,
OPENGROK_CONFIG_FILE,
tmp_out,
out_file_path,
jar=OPENGROK_JAR,
loglevel=log_level,
)

if out_file and os.path.getsize(out_file) > 0:
shutil.move(tmp_out.name, OPENGROK_CONFIG_FILE)
if out_file_path and os.path.getsize(out_file_path) > 0:
shutil.move(out_file_path, OPENGROK_CONFIG_FILE)
else:
logger.warning(
"Failed to merge read-only configuration, "
"leaving the original in place"
)
if out_file:
os.remove(out_file)
if out_file_path:
os.remove(out_file_path)

sync_enabled = True
if use_projects:
Expand Down
16 changes: 12 additions & 4 deletions tools/src/main/python/opengrok_tools/config_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# CDDL HEADER END

#
# Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
#

import argparse
Expand All @@ -37,10 +37,18 @@
"""


def merge_config_files(read_only, current, out_file, jar,
def merge_config_files(read_only_config_path, current_config_path, out_file_path, jar,
loglevel=logging.INFO):

return config_merge_wrapper([read_only, current, out_file], jar=jar,
"""
:param read_only_config_path: path to the read-only configuration
:param current_config_path: path to the current configuration
:param out_file_path: path to the merged configuration
:param jar: path to the opengrok jar file
:param loglevel: log level
:return: either FAILURE_EXITVAL or SUCCESS_EXITVAL
"""

return config_merge_wrapper([read_only_config_path, current_config_path, out_file_path], jar=jar,
loglevel=loglevel)


Expand Down

0 comments on commit 2568862

Please sign in to comment.