Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recent Files sometimes don't work #10770

Closed
karlitschek opened this issue Aug 20, 2018 · 12 comments
Closed

Recent Files sometimes don't work #10770

karlitschek opened this issue Aug 20, 2018 · 12 comments

Comments

@karlitschek
Copy link
Member

If you click on recent files in the left side bar you should see your recent changed files. This works on my private instance but on cloud.nc.com I only see an empty page.

@nextcloud-bot
Copy link
Member

GitMate.io thinks possibly related issues are #4644 (Jumping to file directly is not working), #5876 ("Allow editing" on a file doesn't work), #7398 (Horizontal scaling - file locking not working?), #3488 (File Upload works but can't upload folder), and #6429 (Locked file).

@MorrisJobke
Copy link
Member

cc @rullzer @nickvergessen @skjnldsv

@koarlmichael
Copy link

Here the same with Nextcloud 14.0.2. I only see an empty page on recent files.

@MorrisJobke
Copy link
Member

Same here:

This request:

/apps/files/api/v1/recent

Just returns nothing:

{"files":[]}

This is how it should look like:

{"files":[{"id":"135","parentId":"2","mtime":1539855850000,"name":"Bildschirmfoto...

Or it should have a decent empty screen:

bildschirmfoto 2018-10-18 um 16 55 54

@MorrisJobke MorrisJobke added the good first issue Small tasks with clear documentation about how and in which place you need to fix things in. label Oct 18, 2018
@violoncelloCH
Copy link
Member

Are there groupfolders active for the users/instances it doesn't work?
I also encountered this one a while ago, but for me it only happens for users which have access to a groupfolder. See nextcloud/groupfolders#124

@MorrisJobke
Copy link
Member

Are there groupfolders active for the users/instances it doesn't work?

On the instance of @karlitschek it isn't.

@karlitschek
Copy link
Member Author

yep. no groupfolders here

@Schmuuu
Copy link

Schmuuu commented Dec 20, 2018

Hi,
I just stumbled across this issue and can confirm it happens on NC15 still. However, I noticed something strange and wonder if the root cause of this issue might be a wrong time range for "recent":
grafik

... the future.
Of course, I don't know why this file will be edited on May 12th in 2034 at 12:15 first, but it seems to be listed due to this fact ;)

@MorrisJobke
Copy link
Member

We just looked into this and the reason for this behavior is that shared folders are not fetched for the "recent files" view:

public function getRecent($limit, $offset = 0) {
$mimetypeLoader = \OC::$server->getMimeTypeLoader();
$mounts = $this->root->getMountsIn($this->path);
$mounts[] = $this->getMountPoint();
$mounts = array_filter($mounts, function (IMountPoint $mount) {
return $mount->getStorage();
});
$storageIds = array_map(function (IMountPoint $mount) {
return $mount->getStorage()->getCache()->getNumericStorageId();
}, $mounts);
/** @var IMountPoint[] $mountMap */
$mountMap = array_combine($storageIds, $mounts);
$folderMimetype = $mimetypeLoader->getId(FileInfo::MIMETYPE_FOLDER);
//todo look into options of filtering path based on storage id (only search in files/ for home storage, filter by share root for shared, etc)
$builder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$query = $builder
->select('f.*')
->from('filecache', 'f')
->andWhere($builder->expr()->in('f.storage', $builder->createNamedParameter($storageIds, IQueryBuilder::PARAM_INT_ARRAY)))
->andWhere($builder->expr()->orX(
// handle non empty folders separate
$builder->expr()->neq('f.mimetype', $builder->createNamedParameter($folderMimetype, IQueryBuilder::PARAM_INT)),
$builder->expr()->eq('f.size', new Literal(0))
))
->orderBy('f.mtime', 'DESC')
->setMaxResults($limit)
->setFirstResult($offset);
$result = $query->execute()->fetchAll();
$files = array_filter(array_map(function (array $entry) use ($mountMap, $mimetypeLoader) {
$mount = $mountMap[$entry['storage']];
$entry['internalPath'] = $entry['path'];
$entry['mimetype'] = $mimetypeLoader->getMimetypeById($entry['mimetype']);
$entry['mimepart'] = $mimetypeLoader->getMimetypeById($entry['mimepart']);
$path = $this->getAbsolutePath($mount, $entry['path']);
if (is_null($path)) {
return null;
}
$fileInfo = new \OC\Files\FileInfo($path, $mount->getStorage(), $entry['internalPath'], $entry, $mount);
return $this->root->createNode($fileInfo->getPath(), $fileInfo);
}, $result));
return array_values(array_filter($files, function (Node $node) {
$relative = $this->getRelativePath($node->getPath());
return $relative !== null && $relative !== '/';
}));
}

It only fetches from real storages with a storage ID that stored in the file cache, but shares are only virtual mount points into the user folder and thus it will not fetch the recent files from them properly.

cc @icewind1991 @rullzer Any clever idea how to also include those subfolders or single files of storages in the SQL query or should we inject them separately somehow?

@MorrisJobke MorrisJobke added feature: sharing and removed good first issue Small tasks with clear documentation about how and in which place you need to fix things in. labels Jan 29, 2019
@rullzer
Copy link
Member

rullzer commented Jan 31, 2019

So. it seems we have code duplication here I think. because we could just use the cache searching. There shared folders work. (it is the thing we use for the dav searches as well). It is not the most effective code but good enough for now I'd say.

@rnwgnr
Copy link

rnwgnr commented Feb 3, 2019

I have a similar issue with "recent" files, the file list is completely empty although i have numerous files uploaded/updated today.
screenshot_2019-02-03_14-41-49

Running NextCloud 15.0.2 with PHP 7.2 and local storage only.

@MorrisJobke
Copy link
Member

Fix is in #14185

@MorrisJobke MorrisJobke added this to the Nextcloud 16 milestone Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants