mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Ensured idempotence of scrobbles with timestamp
This commit is contained in:
parent
89881af8fe
commit
3ae30a5226
11
database.py
11
database.py
@ -107,9 +107,18 @@ def get_track_dict(o):
|
|||||||
|
|
||||||
def createScrobble(artists,title,time,volatile=False):
|
def createScrobble(artists,title,time,volatile=False):
|
||||||
dblock.acquire()
|
dblock.acquire()
|
||||||
|
|
||||||
|
i = getTrackID(artists,title)
|
||||||
|
|
||||||
|
# idempotence
|
||||||
|
if time in SCROBBLESDICT:
|
||||||
|
if i == SCROBBLESDICT[time].track:
|
||||||
|
dblock.release()
|
||||||
|
return get_track_dict(TRACKS[i])
|
||||||
|
# timestamp as unique identifier
|
||||||
while (time in SCROBBLESDICT):
|
while (time in SCROBBLESDICT):
|
||||||
time += 1
|
time += 1
|
||||||
i = getTrackID(artists,title)
|
|
||||||
obj = Scrobble(i,time,volatile) # if volatile generated, we simply pretend we have already saved it to disk
|
obj = Scrobble(i,time,volatile) # if volatile generated, we simply pretend we have already saved it to disk
|
||||||
#SCROBBLES.append(obj)
|
#SCROBBLES.append(obj)
|
||||||
# immediately insert scrobble correctly so we can guarantee sorted list
|
# immediately insert scrobble correctly so we can guarantee sorted list
|
||||||
|
Loading…
Reference in New Issue
Block a user