2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 11:36:44 +00:00

fix(contrib): move imports to ensure task startup without django is possible (#9057)

This commit is contained in:
Matthias Mair 2025-02-10 02:21:43 +01:00 committed by GitHub
parent ded1cfaa45
commit 33d0449460
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,9 +10,6 @@ import string
import warnings
from pathlib import Path
from django.core.files.base import ContentFile
from django.core.files.storage import Storage
logger = logging.getLogger('inventree')
CONFIG_DATA = None
CONFIG_LOOKUPS = {}
@ -77,6 +74,9 @@ def ensure_dir(path: Path, storage=None) -> None:
If it does not exist, create it.
"""
from django.core.files.base import ContentFile
from django.core.files.storage import Storage
if storage and isinstance(storage, Storage):
if not storage.exists(str(path)):
storage.save(str(path / '.empty'), ContentFile(''))