Ensure all creations of directories create the parents too (#5711)

This commit is contained in:
Trenton H
2024-02-10 11:02:40 -08:00
committed by GitHub
parent 0b1523f4e5
commit 13201dbfff
11 changed files with 22 additions and 38 deletions

View File

@@ -904,7 +904,7 @@ class PostDocumentView(GenericAPIView):
t = int(mktime(datetime.now().timetuple()))
os.makedirs(settings.SCRATCH_DIR, exist_ok=True)
settings.SCRATCH_DIR.mkdir(parents=True, exist_ok=True)
temp_file_path = Path(tempfile.mkdtemp(dir=settings.SCRATCH_DIR)) / Path(
pathvalidate.sanitize_filename(doc_name),
@@ -1136,7 +1136,7 @@ class BulkDownloadView(GenericAPIView):
content = serializer.validated_data.get("content")
follow_filename_format = serializer.validated_data.get("follow_formatting")
os.makedirs(settings.SCRATCH_DIR, exist_ok=True)
settings.SCRATCH_DIR.mkdir(parents=True, exist_ok=True)
temp = tempfile.NamedTemporaryFile(
dir=settings.SCRATCH_DIR,
suffix="-compressed-archive",