mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 17:06:17 +00:00
parent
aea8ebeb13
commit
e6e20d1669
@ -11,7 +11,7 @@ import binascii
|
|||||||
import uuid
|
import uuid
|
||||||
from flask import request
|
from flask import request
|
||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
from pony.orm import ObjectNotFound
|
from pony.orm import ObjectNotFound, TransactionIntegrityError
|
||||||
from pony.orm import commit
|
from pony.orm import commit
|
||||||
|
|
||||||
from ..db import ClientPrefs, Folder
|
from ..db import ClientPrefs, Folder
|
||||||
@ -83,8 +83,15 @@ def get_client_prefs():
|
|||||||
try:
|
try:
|
||||||
request.client = ClientPrefs[request.user, client]
|
request.client = ClientPrefs[request.user, client]
|
||||||
except ObjectNotFound:
|
except ObjectNotFound:
|
||||||
|
try:
|
||||||
request.client = ClientPrefs(user=request.user, client_name=client)
|
request.client = ClientPrefs(user=request.user, client_name=client)
|
||||||
commit()
|
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"):
|
def get_entity(cls, param="id"):
|
||||||
|
Loading…
Reference in New Issue
Block a user