Skip to content

Commit

Permalink
Moved when temp folder is cleared on BE startup (#104)
Browse files Browse the repository at this point in the history
Moved when and where temp folder is cleared when starting the backend.
This fixes a bug accidentally introduced earlier, where the sub-temp
folder would be created and then instantly deleted again on startup.
  • Loading branch information
ostepizza authored Apr 10, 2024
1 parent 41bbaca commit 70b3faa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 0 additions & 4 deletions backend/img2mapAPI/Img2mapAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from fastapi.middleware.cors import CORSMiddleware
from img2mapAPI.routers import *
from dotenv import load_dotenv, get_key
from .utils.core.FileHelper import clearTmpFolder
import os

#setting the default environment to development
Expand Down Expand Up @@ -81,9 +80,6 @@
allow_headers=["*"],
)

# Clear files in the temp folder
clearTmpFolder()

# Default route
@router.get("/")
async def root():
Expand Down
4 changes: 4 additions & 0 deletions backend/img2mapAPI/utils/storage/files/localFileStorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
import shutil
import tempfile
from .fileStorage import FileStorage
from ...core.FileHelper import clearTmpFolder
from fastapi import UploadFile

_tempPath = "./temp"
if not os.path.exists(_tempPath):
os.makedirs(_tempPath)

# Clear files in the temp folder
clearTmpFolder()

#File storage using the local file system
class LocalFileStorage(FileStorage):
#temp folder should be in main script folder
Expand Down

0 comments on commit 70b3faa

Please sign in to comment.