mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
Fix TOCTOU Race Conditions when creating directories (#4587)
* fixed division by 0
* fixed division by 0
* fixed division by 0
* updated lock file
* Revert "fixed division by 0"
This reverts commit b916a0c9c9.
* Add tests for turn_animation_into_updater with zero/negative run_time
* updated lock file
* tests
---------
Co-authored-by: Benjamin Hackl <mail@behackl.dev>
This commit is contained in:
parent
c261c61dfd
commit
7efa45492f
3 changed files with 5 additions and 9 deletions
|
|
@ -801,8 +801,7 @@ class Text(SVGMobject):
|
|||
line_spacing /= TEXT2SVG_ADJUSTMENT_FACTOR
|
||||
|
||||
dir_name = config.get_dir("text_dir")
|
||||
if not dir_name.is_dir():
|
||||
dir_name.mkdir(parents=True)
|
||||
dir_name.mkdir(parents=True, exist_ok=True)
|
||||
hash_name = self._text2hash(color)
|
||||
file_name = dir_name / (hash_name + ".svg")
|
||||
|
||||
|
|
@ -1349,8 +1348,7 @@ class MarkupText(SVGMobject):
|
|||
line_spacing /= TEXT2SVG_ADJUSTMENT_FACTOR
|
||||
|
||||
dir_name = config.get_dir("text_dir")
|
||||
if not dir_name.is_dir():
|
||||
dir_name.mkdir(parents=True)
|
||||
dir_name.mkdir(parents=True, exist_ok=True)
|
||||
hash_name = self._text2hash(color)
|
||||
file_name = dir_name / (hash_name + ".svg")
|
||||
|
||||
|
|
|
|||
|
|
@ -153,15 +153,14 @@ def add_version_before_extension(file_name: Path) -> Path:
|
|||
|
||||
|
||||
def guarantee_existence(path: Path) -> Path:
|
||||
if not path.exists():
|
||||
path.mkdir(parents=True)
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
return path.resolve(strict=True)
|
||||
|
||||
|
||||
def guarantee_empty_existence(path: Path) -> Path:
|
||||
if path.exists():
|
||||
shutil.rmtree(str(path))
|
||||
path.mkdir(parents=True)
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
return path.resolve(strict=True)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -103,8 +103,7 @@ def generate_tex_file(
|
|||
output = tex_template.get_texcode_for_expression(expression)
|
||||
|
||||
tex_dir = config.get_dir("tex_dir")
|
||||
if not tex_dir.exists():
|
||||
tex_dir.mkdir()
|
||||
tex_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
result = tex_dir / (tex_hash(output) + ".tex")
|
||||
if not result.exists():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue