mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Merge pull request #2637 from nextcloud/mount-cache-storageid
also compare storage ids when checking for changed mounts
This commit is contained in:
commit
edd01e3ce4
4 changed files with 26 additions and 19 deletions
|
|
@ -130,12 +130,12 @@ class SharedMount extends MountPoint implements MoveableMount {
|
|||
*/
|
||||
private function generateUniqueTarget($path, $view, array $mountpoints) {
|
||||
$pathinfo = pathinfo($path);
|
||||
$ext = (isset($pathinfo['extension'])) ? '.'.$pathinfo['extension'] : '';
|
||||
$ext = (isset($pathinfo['extension'])) ? '.' . $pathinfo['extension'] : '';
|
||||
$name = $pathinfo['filename'];
|
||||
$dir = $pathinfo['dirname'];
|
||||
|
||||
// Helper function to find existing mount points
|
||||
$mountpointExists = function($path) use ($mountpoints) {
|
||||
$mountpointExists = function ($path) use ($mountpoints) {
|
||||
foreach ($mountpoints as $mountpoint) {
|
||||
if ($mountpoint->getShare()->getTarget() === $path) {
|
||||
return true;
|
||||
|
|
@ -146,7 +146,7 @@ class SharedMount extends MountPoint implements MoveableMount {
|
|||
|
||||
$i = 2;
|
||||
while ($view->file_exists($path) || $mountpointExists($path)) {
|
||||
$path = Filesystem::normalizePath($dir . '/' . $name . ' ('.$i.')' . $ext);
|
||||
$path = Filesystem::normalizePath($dir . '/' . $name . ' (' . $i . ')' . $ext);
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
|
@ -240,18 +240,22 @@ class SharedMount extends MountPoint implements MoveableMount {
|
|||
* @return int
|
||||
*/
|
||||
public function getNumericStorageId() {
|
||||
$builder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
|
||||
if (!is_null($this->getShare()->getNodeCacheEntry())) {
|
||||
return $this->getShare()->getNodeCacheEntry()->getStorageId();
|
||||
} else {
|
||||
$builder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
|
||||
|
||||
$query = $builder->select('storage')
|
||||
->from('filecache')
|
||||
->where($builder->expr()->eq('fileid', $builder->createNamedParameter($this->getStorageRootId())));
|
||||
$query = $builder->select('storage')
|
||||
->from('filecache')
|
||||
->where($builder->expr()->eq('fileid', $builder->createNamedParameter($this->getStorageRootId())));
|
||||
|
||||
$result = $query->execute();
|
||||
$row = $result->fetch();
|
||||
$result->closeCursor();
|
||||
if ($row) {
|
||||
return $row['storage'];
|
||||
$result = $query->execute();
|
||||
$row = $result->fetch();
|
||||
$result->closeCursor();
|
||||
if ($row) {
|
||||
return $row['storage'];
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ class Cache implements ICache {
|
|||
}
|
||||
return $data;
|
||||
} else {
|
||||
return self::cacheEntryFromData($data, $this->storageId, $this->mimetypeLoader);
|
||||
return self::cacheEntryFromData($data, $this->mimetypeLoader);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -150,11 +150,10 @@ class Cache implements ICache {
|
|||
* Create a CacheEntry from database row
|
||||
*
|
||||
* @param array $data
|
||||
* @param string $storageId
|
||||
* @param IMimeTypeLoader $mimetypeLoader
|
||||
* @return CacheEntry
|
||||
*/
|
||||
public static function cacheEntryFromData($data, $storageId, IMimeTypeLoader $mimetypeLoader) {
|
||||
public static function cacheEntryFromData($data, IMimeTypeLoader $mimetypeLoader) {
|
||||
//fix types
|
||||
$data['fileid'] = (int)$data['fileid'];
|
||||
$data['parent'] = (int)$data['parent'];
|
||||
|
|
@ -163,7 +162,7 @@ class Cache implements ICache {
|
|||
$data['storage_mtime'] = (int)$data['storage_mtime'];
|
||||
$data['encryptedVersion'] = (int)$data['encrypted'];
|
||||
$data['encrypted'] = (bool)$data['encrypted'];
|
||||
$data['storage'] = $storageId;
|
||||
$data['storage_id'] = $data['storage'];
|
||||
$data['mimetype'] = $mimetypeLoader->getMimetypeById($data['mimetype']);
|
||||
$data['mimepart'] = $mimetypeLoader->getMimetypeById($data['mimepart']);
|
||||
if ($data['storage_mtime'] == 0) {
|
||||
|
|
|
|||
|
|
@ -141,7 +141,11 @@ class UserMountCache implements IUserMountCache {
|
|||
foreach ($cachedMounts as $cachedMount) {
|
||||
if (
|
||||
$newMount->getRootId() === $cachedMount->getRootId() &&
|
||||
($newMount->getMountPoint() !== $cachedMount->getMountPoint() || $newMount->getMountId() !== $cachedMount->getMountId())
|
||||
(
|
||||
$newMount->getMountPoint() !== $cachedMount->getMountPoint() ||
|
||||
$newMount->getStorageId() !== $cachedMount->getStorageId() ||
|
||||
$newMount->getMountId() !== $cachedMount->getMountId()
|
||||
)
|
||||
) {
|
||||
$changed[] = $newMount;
|
||||
}
|
||||
|
|
@ -169,6 +173,7 @@ class UserMountCache implements IUserMountCache {
|
|||
$builder = $this->connection->getQueryBuilder();
|
||||
|
||||
$query = $builder->update('mounts')
|
||||
->set('storage_id', $builder->createNamedParameter($mount->getStorageId()))
|
||||
->set('mount_point', $builder->createNamedParameter($mount->getMountPoint()))
|
||||
->set('mount_id', $builder->createNamedParameter($mount->getMountId(), IQueryBuilder::PARAM_INT))
|
||||
->where($builder->expr()->eq('user_id', $builder->createNamedParameter($mount->getUser()->getUID())))
|
||||
|
|
|
|||
|
|
@ -853,7 +853,6 @@ class DefaultShareProvider implements IShareProvider {
|
|||
$entryData['permissions'] = $entryData['f_permissions'];
|
||||
$entryData['parent'] = $entryData['f_parent'];;
|
||||
$share->setNodeCacheEntry(Cache::cacheEntryFromData($entryData,
|
||||
$entryData['storage_string_id'],
|
||||
\OC::$server->getMimeTypeLoader()));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue