-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix] Creating new temporary directory for zip files #4237
Conversation
@@ -894,7 +894,18 @@ def main(args): | |||
port, | |||
product_name=product_name) | |||
|
|||
zip_file_handle, zip_file = tempfile.mkstemp('.zip') | |||
temp_dir = "/".join([args.input[0], "tmp"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, use the python pathlib for building file paths so the implementation is more platform independent.
zip_file_handle, zip_file = tempfile.mkstemp('.zip') | ||
temp_dir = "/".join([args.input[0], "tmp"]) | ||
try: | ||
if not os.path.exists(temp_dir): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if temp_dir
already exists?
@@ -894,7 +894,16 @@ def main(args): | |||
port, | |||
product_name=product_name) | |||
|
|||
zip_file_handle, zip_file = tempfile.mkstemp('.zip') | |||
try: | |||
temp_dir = tempfile.mkdtemp(suffix="tmp", dir=args.input[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
temp_dir = tempfile.mkdtemp(suffix="tmp", dir=args.input[0]) | |
temp_dir = tempfile.mkdtemp(suffix="-store", dir=args.input[0]) |
We could be explicit about the fact (for posthumous spelunking of crashes at least) that the directory was caused by a store
command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea, much more trackable.
@@ -1007,3 +1016,4 @@ def main(args): | |||
finally: | |||
os.close(zip_file_handle) | |||
os.remove(zip_file) | |||
os.rmdir(temp_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the right approach?
https://docs.python.org/3/library/os.html#os.rmdir
If the directory does not exist or is not empty, a FileNotFoundError or an OSError is raised respectively.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. The deletion is not recursive in this way. I've already fixed it with using shutil.rmtree()
During the storage, the zip files should be stored in one of the report folders instead of /tmp. Storing huge zip files can cause storage space saturation in /tmp. CodeChecker store would create a new tmp directory in the first given report folder where the zip files can be stored temporarily.
In an earlier PR (Ericsson#4237) there was a development about placing temporary files in the report directory instead of /tmp, since some systems have limited resourced in the /tmp folder. This PR is a continuation of this work: some other temporary files during storage are put to the report folder.
In an earlier PR (Ericsson#4237) there was a development about placing temporary files in the report directory instead of /tmp, since some systems have limited resourced in the /tmp folder. This PR is a continuation of this work: some other temporary files during storage are put to the report folder.
During the storage, the zip files should be stored in one of the report folders instead of
/tmp
. Storing huge zip files can cause storage space saturation in/tmp
.CodeChecker store
would create a new tmp directory in the first given report folder where the zip files can be stored temporarily.