fix(files_sharing): Use session id as part of cache key to avoid concurrency issues

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 <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2025-03-13 17:11:40 +01:00
parent d9b2178ee1
commit 8b41055297
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A

View file

@ -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);
}