mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 08:56:17 +00:00
parent
aea8ebeb13
commit
e6e20d1669
@ -11,7 +11,7 @@ import binascii
|
||||
import uuid
|
||||
from flask import request
|
||||
from flask import Blueprint
|
||||
from pony.orm import ObjectNotFound
|
||||
from pony.orm import ObjectNotFound, TransactionIntegrityError
|
||||
from pony.orm import commit
|
||||
|
||||
from ..db import ClientPrefs, Folder
|
||||
@ -83,8 +83,15 @@ def get_client_prefs():
|
||||
try:
|
||||
request.client = ClientPrefs[request.user, client]
|
||||
except ObjectNotFound:
|
||||
try:
|
||||
request.client = ClientPrefs(user=request.user, client_name=client)
|
||||
commit()
|
||||
except TransactionIntegrityError:
|
||||
# We might have hit a race condition here, another request already created
|
||||
# the ClientPrefs. Issue #220
|
||||
# Reload the user or Pony will complain about different transactions
|
||||
request.user = UserManager.get(request.user.id)
|
||||
request.client = ClientPrefs[request.user, client]
|
||||
|
||||
|
||||
def get_entity(cls, param="id"):
|
||||
|
Loading…
Reference in New Issue
Block a user