Skip to content

Commit

Permalink
fix: cast file length only if exists (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariajgrimaldi authored Nov 16, 2023
1 parent 9af9900 commit eefdba7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions filesmanager/filesmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def sync_with_course_assets(self):
course_assets_ids = [asset["id"] for asset in self.get_all_serialized_assets()]
directories_files = self.get_all_files(self.directories["children"])
for file in directories_files:
if file["metadata"]["id"] not in course_assets_ids:
if file["metadata"].get("id") not in course_assets_ids:
self.delete_file_from_directory(file)

def delete_file_from_directory(self, file):
Expand Down Expand Up @@ -746,7 +746,7 @@ def get_asset_json_from_content(self, content):
"display_name": content.name,
"url": str(asset_url),
"content_type": content.content_type,
"file_size": int(content.length),
"file_size": int(content.length) if content.length else 0,
"external_url": urljoin(configuration_helpers.get_value('LMS_ROOT_URL', settings.LMS_ROOT_URL), asset_url),
"thumbnail": urljoin(configuration_helpers.get_value('LMS_ROOT_URL', settings.LMS_ROOT_URL), thumbnail_url),
"uploaded_at": datetime.now().isoformat()
Expand Down

0 comments on commit eefdba7

Please sign in to comment.