Skip to content

Commit

Permalink
Merge pull request #3322 from Minnozz/fix-font-download
Browse files Browse the repository at this point in the history
Fix font download
  • Loading branch information
mouse-reeve committed Mar 23, 2024
2 parents 3cde6db + 7690247 commit 20db968
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 8 additions & 7 deletions bookwyrm/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Do further startup configuration and initialization"""

import os
import urllib
import logging
Expand All @@ -14,16 +15,16 @@ def download_file(url, destination):
"""Downloads a file to the given path"""
try:
# Ensure our destination directory exists
os.makedirs(os.path.dirname(destination))
os.makedirs(os.path.dirname(destination), exist_ok=True)
with urllib.request.urlopen(url) as stream:
with open(destination, "b+w") as outfile:
outfile.write(stream.read())
except (urllib.error.HTTPError, urllib.error.URLError):
logger.info("Failed to download file %s", url)
except OSError:
logger.info("Couldn't open font file %s for writing", destination)
except: # pylint: disable=bare-except
logger.info("Unknown error in file download")
except (urllib.error.HTTPError, urllib.error.URLError) as err:
logger.error("Failed to download file %s: %s", url, err)
except OSError as err:
logger.error("Couldn't open font file %s for writing: %s", destination, err)
except Exception as err: # pylint:disable=broad-except
logger.error("Unknown error in file download: %s", err)


class BookwyrmConfig(AppConfig):
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ services:
env_file: .env
volumes:
- .:/app
- static_volume:/app/static
networks:
- main
depends_on:
Expand Down

0 comments on commit 20db968

Please sign in to comment.