Commit 35ec8d11 authored by Naoki Fukino's avatar Naoki Fukino Committed by Commit Bot

Files app: Retrieve all files under media-view's root to provide flatten views.

In FileSystem API level, the "Audio" media view has a directory structure like
Audio/{Artist}/{Song}.aac. We can't limit the level of recursion up to 1 to
find entries for "Audio".

Actually, a file will not be shown in multiple folders in media view hierarchy,
since no folders will be added in media documents provider.
We don't need to limit the level of recursion.

Bug: 870532
Test: Manually tested on arc-enabled kevin with voice recording app installed.
Change-Id: I1087b9c6e11812025d8456eef8dbec9faeb29cd0
Reviewed-on: https://chromium-review.googlesource.com/1164865
Commit-Queue: Naoki Fukino <fukino@chromium.org>
Reviewed-by: default avatarShuhei Takahashi <nya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581484}
parent 6048aabe
...@@ -333,34 +333,24 @@ function MediaViewContentScanner(rootEntry) { ...@@ -333,34 +333,24 @@ function MediaViewContentScanner(rootEntry) {
MediaViewContentScanner.prototype.__proto__ = ContentScanner.prototype; MediaViewContentScanner.prototype.__proto__ = ContentScanner.prototype;
/** /**
* This scanner provides flattened view of media providers. In each view all * This scanner provides flattened view of media providers.
* media-view files are located just under the root directory and the root
* directory doesn't have any directories (i.e. Directories are ignored).
*
* In FileSystem API level, the root directory contains only directories, and
* all files are guaranteed to be located inside first-level directories.
* For example, in Pictures view, we have directories in the first level and
* files in the second level.
*
* Pictures/
* DCIM/
* a.jpg
* Snapsheed/
* foo.jpg
*
* We can retrieve all files by scanning directories up to one level.
* *
* In FileSystem API level, each media-view root directory has directory
* hierarchy. We need to list files under the root directory to provide flatten
* view. A file will not be shown in multiple directories in media-view
* hierarchy since no folders will be added in media documents provider. We can
* list all files without duplication by just retrieveing files in directories
* recursively.
* @override * @override
*/ */
MediaViewContentScanner.prototype.scan = function( MediaViewContentScanner.prototype.scan = function(
entriesCallback, successCallback, errorCallback) { entriesCallback, successCallback, errorCallback) {
// To provide flatten view of files, it is enough to retrieve file recursively // To provide flatten view of files, this media-view scanner retrieves files
// up to one level from the root. // in directories inside the media's root entry recursively.
const recursionLevel = 1;
util.readEntriesRecursively( util.readEntriesRecursively(
this.rootEntry_, this.rootEntry_,
entries => entriesCallback(entries.filter(entry => !entry.isDirectory)), entries => entriesCallback(entries.filter(entry => !entry.isDirectory)),
successCallback, errorCallback, () => false, recursionLevel); successCallback, errorCallback, () => false);
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment