mirror of
https://github.com/krateng/maloja.git
synced 2025-04-15 16:30:32 +03:00
Fixed cache trimming
This commit is contained in:
parent
a367c7c573
commit
bde06deb4f
@ -90,11 +90,11 @@ class APIHandler:
|
||||
|
||||
|
||||
def scrobble(self,artiststr,titlestr,time=None,duration=None,album=None):
|
||||
logmsg = "Incoming scrobble (API: {api}): ARTISTS: {artiststr}, TRACK: {titlestr}"
|
||||
logmsg = "API receiving scrobble: (API: {api}): ARTISTS: {artiststr}, TRACK: {titlestr}"
|
||||
log(logmsg.format(api=self.__apiname__,artiststr=artiststr,titlestr=titlestr))
|
||||
if time is None: time = int(datetime.datetime.now(tz=datetime.timezone.utc).timestamp())
|
||||
|
||||
# fixing etc is handled by the main scrobble function
|
||||
try:
|
||||
(artists,title) = cla.fullclean(artiststr,titlestr)
|
||||
database.incoming_scrobble(artists=artists,title=title,time=time)
|
||||
database.incoming_scrobble(artists=[artiststr],title=titlestr,time=time,duration=duration,album=album)
|
||||
except:
|
||||
raise ScrobblingException()
|
||||
|
@ -63,8 +63,8 @@ def trim_cache():
|
||||
log(f"{ramprct}% RAM usage, reducing caches!")
|
||||
ratio = (malojaconfig["DB_MAX_MEMORY"] / ramprct) ** 3
|
||||
targetsize = max(int(len(cache) * ratio),100)
|
||||
c.set_size(targetsize)
|
||||
c.set_size(HIGH_NUMBER)
|
||||
cache.set_size(targetsize)
|
||||
cache.set_size(HIGH_NUMBER)
|
||||
log(f"New RAM usage: {psutil.virtual_memory().percent}%")
|
||||
|
||||
|
||||
|
@ -576,7 +576,7 @@ def get_artist(id):
|
||||
@runhourly
|
||||
def clean_db():
|
||||
with engine.begin() as conn:
|
||||
log(f"Database Cleanup...")
|
||||
#log(f"Database Cleanup...")
|
||||
|
||||
### Delete tracks that have no scrobbles (delete their trackartist entries first)
|
||||
a1 = conn.execute(sql.text('''
|
||||
|
Loading…
x
Reference in New Issue
Block a user