diff options
Diffstat (limited to 'lib/private/Files')
-rw-r--r-- | lib/private/Files/Config/UserMountCache.php | 36 | ||||
-rw-r--r-- | lib/private/Files/Stream/SeekableHttpStream.php | 8 |
2 files changed, 26 insertions, 18 deletions
diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index 3540b563742..b4104a14cb6 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -83,38 +83,39 @@ class UserMountCache implements IUserMountCache { } }, $mounts); $newMounts = array_values(array_filter($newMounts)); - $newMountRootIds = array_map(function (ICachedMountInfo $mount) { - return $mount->getRootId(); + $newMountKeys = array_map(function (ICachedMountInfo $mount) { + return $mount->getRootId() . '::' . $mount->getMountPoint(); }, $newMounts); - $newMounts = array_combine($newMountRootIds, $newMounts); + $newMounts = array_combine($newMountKeys, $newMounts); $cachedMounts = $this->getMountsForUser($user); if (is_array($mountProviderClasses)) { $cachedMounts = array_filter($cachedMounts, function (ICachedMountInfo $mountInfo) use ($mountProviderClasses, $newMounts) { // for existing mounts that didn't have a mount provider set // we still want the ones that map to new mounts - if ($mountInfo->getMountProvider() === '' && isset($newMounts[$mountInfo->getRootId()])) { + $mountKey = $mountInfo->getRootId() . '::' . $mountInfo->getMountPoint(); + if ($mountInfo->getMountProvider() === '' && isset($newMounts[$mountKey])) { return true; } return in_array($mountInfo->getMountProvider(), $mountProviderClasses); }); } - $cachedMountRootIds = array_map(function (ICachedMountInfo $mount) { - return $mount->getRootId(); + $cachedRootKeys = array_map(function (ICachedMountInfo $mount) { + return $mount->getRootId() . '::' . $mount->getMountPoint(); }, $cachedMounts); - $cachedMounts = array_combine($cachedMountRootIds, $cachedMounts); + $cachedMounts = array_combine($cachedRootKeys, $cachedMounts); $addedMounts = []; $removedMounts = []; - foreach ($newMounts as $rootId => $newMount) { - if (!isset($cachedMounts[$rootId])) { + foreach ($newMounts as $mountKey => $newMount) { + if (!isset($cachedMounts[$mountKey])) { $addedMounts[] = $newMount; } } - foreach ($cachedMounts as $rootId => $cachedMount) { - if (!isset($newMounts[$rootId])) { + foreach ($cachedMounts as $mountKey => $cachedMount) { + if (!isset($newMounts[$mountKey])) { $removedMounts[] = $cachedMount; } } @@ -144,13 +145,13 @@ class UserMountCache implements IUserMountCache { private function findChangedMounts(array $newMounts, array $cachedMounts) { $new = []; foreach ($newMounts as $mount) { - $new[$mount->getRootId()] = $mount; + $new[$mount->getRootId() . '::' . $mount->getMountPoint()] = $mount; } $changed = []; foreach ($cachedMounts as $cachedMount) { - $rootId = $cachedMount->getRootId(); - if (isset($new[$rootId])) { - $newMount = $new[$rootId]; + $key = $cachedMount->getRootId() . '::' . $cachedMount->getMountPoint(); + if (isset($new[$key])) { + $newMount = $new[$key]; if ( $newMount->getMountPoint() !== $cachedMount->getMountPoint() || $newMount->getStorageId() !== $cachedMount->getStorageId() || @@ -173,7 +174,7 @@ class UserMountCache implements IUserMountCache { 'mount_point' => $mount->getMountPoint(), 'mount_id' => $mount->getMountId(), 'mount_provider_class' => $mount->getMountProvider(), - ], ['root_id', 'user_id']); + ], ['root_id', 'user_id', 'mount_point']); } else { // in some cases this is legitimate, like orphaned shares $this->logger->debug('Could not get storage info for mount at ' . $mount->getMountPoint()); @@ -199,7 +200,8 @@ class UserMountCache implements IUserMountCache { $query = $builder->delete('mounts') ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($mount->getUser()->getUID()))) - ->andWhere($builder->expr()->eq('root_id', $builder->createNamedParameter($mount->getRootId(), IQueryBuilder::PARAM_INT))); + ->andWhere($builder->expr()->eq('root_id', $builder->createNamedParameter($mount->getRootId(), IQueryBuilder::PARAM_INT))) + ->andWhere($builder->expr()->eq('mount_point', $builder->createNamedParameter($mount->getMountPoint()))); $query->execute(); } diff --git a/lib/private/Files/Stream/SeekableHttpStream.php b/lib/private/Files/Stream/SeekableHttpStream.php index df37fd29f42..e53c20b5900 100644 --- a/lib/private/Files/Stream/SeekableHttpStream.php +++ b/lib/private/Files/Stream/SeekableHttpStream.php @@ -78,6 +78,7 @@ class SeekableHttpStream implements File { private int $offset = 0; private int $length = 0; private bool $needReconnect = false; + private int $totalSize = 0; private function reconnect(int $start): bool { $this->needReconnect = false; @@ -128,6 +129,9 @@ class SeekableHttpStream implements File { $this->offset = $begin; $this->length = $length; + if ($start === 0) { + $this->totalSize = $length; + } return true; } @@ -211,7 +215,9 @@ class SeekableHttpStream implements File { public function stream_stat() { if ($this->getCurrent()) { - return fstat($this->getCurrent()); + $stat = fstat($this->getCurrent()); + $stat['size'] = $this->totalSize; + return $stat; } else { return false; } |