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 committed by Côme Chilliet
parent ec5ac0957a
commit a32875d402

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