handled bug cannot create secret in empty file

This commit is contained in:
Gourav Kumar 2024-06-16 12:23:41 +05:30
parent 334bb97d35
commit 3f1ddacce3

View File

@ -131,7 +131,11 @@ async def create_secret(secret: Secret, current_user: dict = Depends(get_current
text = f.read()
if text:
data.extend(json.loads(text))
secret_id = max(i['id'] for i in data) + 1
if data:
secret_id = max(i['id'] for i in data) + 1
else:
secret_id = 0
secret.id = secret_id
secret.user_id = current_user['id']
encryption_key = current_user['encryption_key'].encode()