From 7a5b96c7546cd34660bb50c1ab84818be92f87e5 Mon Sep 17 00:00:00 2001
From: David Trattnig <david.trattnig@o94.at>
Date: Mon, 8 Jun 2020 14:49:38 +0200
Subject: [PATCH] Resolve filepath dynamically.

---
 modules/core/state.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/modules/core/state.py b/modules/core/state.py
index a571a680..4f12aade 100644
--- a/modules/core/state.py
+++ b/modules/core/state.py
@@ -21,7 +21,7 @@ import logging
 from collections import deque
 
 from modules.base.exceptions        import NoActiveEntryException
-from modules.base.utils             import SimpleUtil
+from modules.base.utils             import SimpleUtil, EngineUtil
 from modules.database.model         import SingleEntry, SingleEntryMetaData, PlaylistEntry, PlaylistEntryMetaData, TrackService
 
 
@@ -73,12 +73,12 @@ class PlayerStateService:
         return self.entry_history[0]
 
 
-    def store_trackservice_entry(self, source):
+    def store_trackservice_entry(self, filepath):
         """
         Stores the entry identified by the given source in the Track Service.
 
         Args:
-            source (String):    The URI of the currently playing source
+            filepath (String):    The path of the currently playing file
 
         Raises:
             (NoActiveEntryException):    In case currently nothing is playing
@@ -90,7 +90,8 @@ class PlayerStateService:
             raise NoActiveEntryException
 
         for active_entry in entries:
-            if active_entry.source == source:
+            base_dir = self.config.get("audiofolder")
+            if EngineUtil.uri_to_filepath(base_dir, active_entry.source) == filepath:
                 trackservice = TrackService(active_entry)
                 trackservice.store(add=True, commit=True)
 
@@ -101,7 +102,7 @@ class PlayerStateService:
                 found = True
 
         if not found:
-            msg = "Found no entry in the recent history which matches the given source '%s'" % (source)
+            msg = "Found no entry in the recent history which matches the given source '%s'" % (filepath)
             self.logger.critical(SimpleUtil.red(msg))
 
 
-- 
GitLab