Skip to content

Commit c595333

Browse files
committed
Rewrite path selection in EAFP
1 parent e6eed48 commit c595333

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
@@ -924,18 +924,21 @@ def main(args):
924924
# If the --temp_dir argument is specified set use that,
925925
# else use the analyze result folder
926926
temp_dir_path: str = args.temp_dir if args.temp_dir else args.input[0]
927-
if not os.access(temp_dir_path, os.W_OK):
928-
# If the specified folder isn't writeable; fallback to /tmp/
929-
LOG.debug("'%s' is readonly, falling back to /tmp", temp_dir_path)
930-
temp_dir_path = "/tmp"
931927
try:
932928
temp_dir = tempfile.mkdtemp(suffix="-store", dir=temp_dir_path)
933929
LOG.debug(f"{temp_dir} directory created successfully!")
934930
except PermissionError:
935-
LOG.error(f"Permission denied! You do not have sufficient "
936-
f"permissions to create the {temp_dir} "
937-
"temporary directory.")
938-
sys.exit(1)
931+
try:
932+
# If the specified folder isn't writeable; fallback to /tmp/
933+
LOG.debug("'%s' is readonly, falling back to /tmp", temp_dir_path)
934+
temp_dir_path = "/tmp"
935+
temp_dir = tempfile.mkdtemp(suffix="-store", dir=temp_dir_path)
936+
LOG.debug(f"{temp_dir} directory created successfully!")
937+
except:
938+
LOG.error(f"Permission denied! You do not have sufficient "
939+
f"permissions to create the {temp_dir} "
940+
"temporary directory.")
941+
sys.exit(1)
939942

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

0 commit comments

Comments
 (0)