-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task/DES-abc: Move project asset directory deletion to celery task (#118
) * Move project assset directory deletion to celery task * Add mock * Add remove_project_assets to __init__.py
- Loading branch information
1 parent
34d028e
commit db37557
Showing
6 changed files
with
55 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from geoapi.tasks.lidar import convert_to_potree | ||
from geoapi.tasks.external_data import import_file_from_agave, import_from_agave, refresh_observable_projects | ||
from geoapi.tasks.streetview import publish, from_tapis_to_streetview, process_streetview_sequences | ||
from geoapi.tasks.projects import remove_project_assets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from geoapi.celery_app import app | ||
from geoapi.utils.assets import get_project_asset_dir | ||
from geoapi.log import logger | ||
import shutil | ||
|
||
|
||
@app.task() | ||
def remove_project_assets(project_id): | ||
""" | ||
Remove all assets associated with a project. | ||
The directory containing that project's assets will be deleted. | ||
""" | ||
logger.info(f"Deleting project:{project_id} started") | ||
assets_folder = get_project_asset_dir(project_id) | ||
try: | ||
shutil.rmtree(assets_folder) | ||
logger.info(f"Deleting project:{project_id} finished") | ||
except FileNotFoundError: | ||
logger.info(f"Deleting project:{project_id} completed but caught FileNotFoundError") | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters