| Index: chrome/browser/chromeos/drive/file_system/search_operation.cc
|
| diff --git a/chrome/browser/chromeos/drive/file_system/search_operation.cc b/chrome/browser/chromeos/drive/file_system/search_operation.cc
|
| index 59fcff38bef7e30ed58b5417be47396a383a2462..a1d6b647509bd5382570744fa054e46d2468ac7c 100644
|
| --- a/chrome/browser/chromeos/drive/file_system/search_operation.cc
|
| +++ b/chrome/browser/chromeos/drive/file_system/search_operation.cc
|
| @@ -39,28 +39,30 @@ FileError RefreshEntriesOnBlockingPool(
|
| result->reserve(entries.size());
|
| for (size_t i = 0; i < entries.size(); ++i) {
|
| ResourceEntry entry = ConvertToResourceEntry(*entries[i]);
|
| - base::FilePath drive_file_path;
|
| - FileError error = resource_metadata->RefreshEntry(
|
| - entry, &drive_file_path, &entry);
|
| - if (error == FILE_ERROR_OK) {
|
| - result->push_back(SearchResultInfo(drive_file_path, entry));
|
| - } else if (error == FILE_ERROR_NOT_FOUND) {
|
| - // The result is absent in local resource metadata. There are two cases:
|
| + const std::string id = entry.resource_id();
|
| + FileError error = resource_metadata->RefreshEntry(entry, NULL, &entry);
|
| + if (error == FILE_ERROR_NOT_FOUND) {
|
| + // The result is absent in local resource metadata. This can happen if
|
| + // the metadata is not synced to the latest server state yet. In that
|
| + // case, we temporarily add the file to the special "drive/other"
|
| + // directory in order to assign a path, which is needed to access the
|
| + // file through FileSystem API.
|
| //
|
| - // 1) Resource metadata is not up-to-date, and the entry has recently
|
| - // been added to the drive. This is not a fatal error, so just skip to
|
| - // add the result. We should soon receive XMPP update notification
|
| - // and refresh both the metadata and search result UI in Files.app.
|
| - //
|
| - // 2) Resource metadata is not fully loaded.
|
| - // TODO(kinaba) crbug.com/181075:
|
| - // In this case, we are doing "fast fetch" fetching directory lists on
|
| - // the fly to quickly deliver results to the user. However, we have no
|
| - // such equivalent for Search.
|
| - } else {
|
| - // Otherwise, it is a fatal error. Give up to return the search result.
|
| - return error;
|
| + // It will be moved to the right place when the metadata gets synced
|
| + // in normal loading process in ChangeListProcessor.
|
| + entry.set_parent_resource_id(util::kDriveOtherDirSpecialResourceId);
|
| + error = resource_metadata->AddEntry(entry);
|
| +
|
| + // FILE_ERROR_EXISTS may happen if we have already added the entry to
|
| + // "drive/other" once before. That's not an error.
|
| + if (error == FILE_ERROR_OK || error == FILE_ERROR_EXISTS)
|
| + error = resource_metadata->GetResourceEntryById(id, &entry);
|
| }
|
| + // Other errors are fatal. Give up to return the search result.
|
| + if (error != FILE_ERROR_OK)
|
| + return error;
|
| + result->push_back(SearchResultInfo(resource_metadata->GetFilePath(id),
|
| + entry));
|
| }
|
|
|
| return FILE_ERROR_OK;
|
|
|