Skip to content

Commit 57ad106

Browse files
committed
Rewrite path selection in EAFP
1 parent 99cca3e commit 57ad106

File tree

1 file changed

+11
-8
lines changed
  • web/client/codechecker_client/cli

1 file changed

+11
-8
lines changed

web/client/codechecker_client/cli/store.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -929,18 +929,21 @@ def main(args):
929929
# If the --temp_dir argument is specified set use that,
930930
# else use the analyze result folder
931931
temp_dir_path: str = args.temp_dir if args.temp_dir else args.input[0]
932-
if not os.access(temp_dir_path, os.W_OK):
933-
# If the specified folder isn't writeable; fallback to /tmp/
934-
LOG.debug("'%s' is readonly, falling back to /tmp", temp_dir_path)
935-
temp_dir_path = "/tmp"
936932
try:
937933
temp_dir = tempfile.mkdtemp(suffix="-store", dir=temp_dir_path)
938934
LOG.debug(f"{temp_dir} directory created successfully!")
939935
except PermissionError:
940-
LOG.error(f"Permission denied! You do not have sufficient "
941-
f"permissions to create the {temp_dir} "
942-
"temporary directory.")
943-
sys.exit(1)
936+
try:
937+
# If the specified folder isn't writeable; fallback to /tmp/
938+
LOG.debug("'%s' is readonly, falling back to /tmp", temp_dir_path)
939+
temp_dir_path = "/tmp"
940+
temp_dir = tempfile.mkdtemp(suffix="-store", dir=temp_dir_path)
941+
LOG.debug(f"{temp_dir} directory created successfully!")
942+
except PermissionError:
943+
LOG.error(f"Permission denied! You do not have sufficient "
944+
f"permissions to create the {temp_dir} "
945+
"temporary directory.")
946+
sys.exit(1)
944947

945948
zip_file_handle, zip_file = tempfile.mkstemp(suffix=".zip", dir=temp_dir)
946949
LOG.debug("Will write mass store ZIP to '%s'...", zip_file)

0 commit comments

Comments
 (0)