Skip to content

Commit

Permalink
Fixed volume path in remote server and missing file ext
Browse files Browse the repository at this point in the history
  • Loading branch information
joemarct committed Aug 12, 2021
1 parent a019b02 commit 8820918
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
11 changes: 11 additions & 0 deletions compose/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@ server {
proxy_set_header X-Forwarded-Host $server_name;
}
}


server {
listen 80;
server_name images.watchtower.cash;

location / {
autoindex on;
root /root/watchtower/token_images;
}
}
2 changes: 1 addition & 1 deletion compose/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
command: [ "supervisord", "-c", "/code/supervisord.conf", "--nodaemon" ]
env_file: /root/watchtower/compose/.env_prod
volumes:
- /root/watchtower/token_images:/images
- /var/www/images:/images
ports:
- 8000:8000
rabbitmq:
Expand Down
8 changes: 4 additions & 4 deletions main/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ def get_token_meta_data(self, token_id):
Token.objects.filter(tokenid=token_id).update(**data)

# Get image / logo URL
image_found = False
image_file_name = None
if data['token_type'] == 1:

# Check icons.fountainhead.cash
Expand All @@ -655,11 +655,11 @@ def get_token_meta_data(self, token_id):
out_path = f"{settings.TOKEN_IMAGES_DIR}/{token_id}.{file_ext}"
with open(out_path, 'wb') as out_file:
shutil.copyfileobj(resp.raw, out_file)
image_found = True
image_file_name = f"{token_id}.{file_ext}"

if image_found:
if image_file_name:
image_server_base = 'https://images.watchtower.cash'
image_url = f"{image_server_base}/{token_id}"
image_url = f"{image_server_base}/{image_file_name}"
Token.objects.filter(tokenid=token_id).update(
image_url=image_url
)
Expand Down
4 changes: 2 additions & 2 deletions main/views/view_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ def get(self, request, *args, **kwargs):
name=F('token__name'),
symbol=F('token__token_ticker'),
type=F('token__token_type'),
logo=F('token__image_url')
image_url=F('token__image_url')
).rename_annotations(
_token='token_id'
).values(
'token_id',
'name',
'symbol',
'type',
'logo'
'image_url'
)
return Response(data=tokens, status=status.HTTP_200_OK)

0 comments on commit 8820918

Please sign in to comment.