From 8b41055297eee6e42c6f05f7fb6cc007d070a30f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 13 Mar 2025 17:11:40 +0100 Subject: [PATCH] fix(files_sharing): Use session id as part of cache key to avoid concurrency issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If several people are watching and seeking the same video file we do not want the cache key to be the same or it would flood activity again. Signed-off-by: Côme Chilliet --- apps/files_sharing/lib/Listener/BeforeNodeReadListener.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/files_sharing/lib/Listener/BeforeNodeReadListener.php b/apps/files_sharing/lib/Listener/BeforeNodeReadListener.php index a4f87467ce0..d19bc8dfae9 100644 --- a/apps/files_sharing/lib/Listener/BeforeNodeReadListener.php +++ b/apps/files_sharing/lib/Listener/BeforeNodeReadListener.php @@ -114,12 +114,12 @@ class BeforeNodeReadListener implements IEventListener { } /* Avoid publishing several activities for one video playing */ - $cacheKey = $node->getId() . $node->getPath(); - if (($this->request->getHeader('range') !== '') && ($this->cache->get($cacheKey) == $this->session->getId())) { + $cacheKey = $node->getId() . $node->getPath() . $this->session->getId(); + if (($this->request->getHeader('range') !== '') && ($this->cache->get($cacheKey) === 'true')) { /* This is a range request and an activity for the same file was published in the same session */ return; } - $this->cache->set($cacheKey, $this->session->getId(), 3600); + $this->cache->set($cacheKey, 'true', 3600); $this->singleFileDownloaded($share, $node); }