Skip to content

Commit 2568862

Browse files
committed
pass output file path instead of file object
fixes #4523
1 parent d768007 commit 2568862

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

docker/start.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# CDDL HEADER END
2323

2424
#
25-
# Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
25+
# Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
2626
#
2727

2828
import logging
@@ -592,28 +592,28 @@ def main():
592592
"Merging read-only configuration from '{}' with current "
593593
"configuration in '{}'".format(read_only_config_file, OPENGROK_CONFIG_FILE)
594594
)
595-
out_file = None
595+
out_file_path = None
596596
with tempfile.NamedTemporaryFile(
597597
mode="w+", delete=False, prefix="merged_config"
598-
) as tmp_out:
599-
out_file = tmp_out.name
598+
) as tmp_out_fobj:
599+
out_file_path = tmp_out_fobj.name
600600
merge_config_files(
601601
read_only_config_file,
602602
OPENGROK_CONFIG_FILE,
603-
tmp_out,
603+
out_file_path,
604604
jar=OPENGROK_JAR,
605605
loglevel=log_level,
606606
)
607607

608-
if out_file and os.path.getsize(out_file) > 0:
609-
shutil.move(tmp_out.name, OPENGROK_CONFIG_FILE)
608+
if out_file_path and os.path.getsize(out_file_path) > 0:
609+
shutil.move(out_file_path, OPENGROK_CONFIG_FILE)
610610
else:
611611
logger.warning(
612612
"Failed to merge read-only configuration, "
613613
"leaving the original in place"
614614
)
615-
if out_file:
616-
os.remove(out_file)
615+
if out_file_path:
616+
os.remove(out_file_path)
617617

618618
sync_enabled = True
619619
if use_projects:

tools/src/main/python/opengrok_tools/config_merge.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# CDDL HEADER END
1919

2020
#
21-
# Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
21+
# Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2222
#
2323

2424
import argparse
@@ -37,10 +37,18 @@
3737
"""
3838

3939

40-
def merge_config_files(read_only, current, out_file, jar,
40+
def merge_config_files(read_only_config_path, current_config_path, out_file_path, jar,
4141
loglevel=logging.INFO):
42-
43-
return config_merge_wrapper([read_only, current, out_file], jar=jar,
42+
"""
43+
:param read_only_config_path: path to the read-only configuration
44+
:param current_config_path: path to the current configuration
45+
:param out_file_path: path to the merged configuration
46+
:param jar: path to the opengrok jar file
47+
:param loglevel: log level
48+
:return: either FAILURE_EXITVAL or SUCCESS_EXITVAL
49+
"""
50+
51+
return config_merge_wrapper([read_only_config_path, current_config_path, out_file_path], jar=jar,
4452
loglevel=loglevel)
4553

4654

0 commit comments

Comments
 (0)