API - check if workouts directory exist before exporting gpx file
+ remove json files
This commit is contained in:
parent
06d4a53fbb
commit
576b3fd66c
@ -76,6 +76,7 @@ class UserDataExporter:
|
||||
zip_object.write(
|
||||
picture_path, self.user.picture.split('/')[-1]
|
||||
)
|
||||
if os.path.exists(self.workouts_directory):
|
||||
for file in os.listdir(self.workouts_directory):
|
||||
if os.path.isfile(
|
||||
os.path.join(self.workouts_directory, file)
|
||||
@ -86,8 +87,11 @@ class UserDataExporter:
|
||||
)
|
||||
|
||||
file_exists = os.path.exists(zip_path)
|
||||
os.remove(user_data_file_name)
|
||||
os.remove(workout_data_file_name)
|
||||
return (zip_path, zip_file) if file_exists else (None, None)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
appLog.error(f'Error when generating user data archive: {str(e)}')
|
||||
return None, None
|
||||
|
||||
|
||||
@ -108,6 +112,7 @@ def export_user_data(export_request_id: int) -> None:
|
||||
exporter = UserDataExporter(user)
|
||||
archive_file_path, archive_file_name = exporter.generate_archive()
|
||||
|
||||
try:
|
||||
export_request.completed = True
|
||||
if archive_file_name and archive_file_path:
|
||||
export_request.file_name = archive_file_name
|
||||
@ -128,3 +133,5 @@ def export_user_data(export_request_id: int) -> None:
|
||||
data_export_email.send(user_data, email_data)
|
||||
else:
|
||||
db.session.commit()
|
||||
except Exception as e:
|
||||
appLog.error(f'Error when exporting user data: {str(e)}')
|
||||
|
Loading…
Reference in New Issue
Block a user