fix(lib): prevent filename collision (#429)

* fix(lib): prevent filename collision

Apparently, ManimCE can produce two different animations with the same name (i.e., the same hash). As documented, ManimGL would any produce files with the same name so this fix was needed.

Closes #428

* chore(lib): update comment

chore(lib): update comment

* chore(tests): add test

* chore(tests): remove redundant underscore

* chore(docs): add changelog entry
This commit is contained in:
Jérome Eertmans
2024-05-18 10:17:25 +02:00
committed by GitHub
parent 993acf0e3f
commit b08073983b
4 changed files with 57 additions and 5 deletions

View File

@ -324,15 +324,19 @@ class PresentationConfig(BaseModel): # type: ignore[misc]
f.write(self.model_dump_json(indent=2))
def copy_to(
self, folder: Path, use_cached: bool = True, include_reversed: bool = True
self,
folder: Path,
use_cached: bool = True,
include_reversed: bool = True,
prefix: str = "",
) -> "PresentationConfig":
"""Copy the files to a given directory."""
for slide_config in self.slides:
file = slide_config.file
rev_file = slide_config.rev_file
dest = folder / file.name
rev_dest = folder / rev_file.name
dest = folder / f"{prefix}{file.name}"
rev_dest = folder / f"{prefix}{rev_file.name}"
slide_config.file = dest
slide_config.rev_file = rev_dest