Chromium Code Reviews| Index: chrome/browser/chromeos/drive/file_system/download_operation.cc |
| diff --git a/chrome/browser/chromeos/drive/file_system/download_operation.cc b/chrome/browser/chromeos/drive/file_system/download_operation.cc |
| index c11457daeb210529b2e24f94436204d3ab016468..7eb7067156e95ea2f128fd2f9770eda5ac6b6b5d 100644 |
| --- a/chrome/browser/chromeos/drive/file_system/download_operation.cc |
| +++ b/chrome/browser/chromeos/drive/file_system/download_operation.cc |
| @@ -37,31 +37,31 @@ namespace { |
| FileError CheckPreConditionForEnsureFileDownloaded( |
| internal::ResourceMetadata* metadata, |
| internal::FileCache* cache, |
| - const ResourceEntry& entry, |
| + ResourceEntry* entry, |
| base::FilePath* cache_file_path) { |
| DCHECK(metadata); |
| DCHECK(cache); |
| DCHECK(cache_file_path); |
| - if (entry.file_info().is_directory()) |
| + if (entry->file_info().is_directory()) |
| return FILE_ERROR_NOT_A_FILE; |
| // The file's entry should have its file specific info. |
| - DCHECK(entry.has_file_specific_info()); |
| + DCHECK(entry->has_file_specific_info()); |
| // For a hosted document, we create a special JSON file to represent the |
| // document instead of fetching the document content in one of the exported |
| // formats. The JSON file contains the edit URL and resource ID of the |
| // document. |
| - if (entry.file_specific_info().is_hosted_document()) { |
| + if (entry->file_specific_info().is_hosted_document()) { |
| base::FilePath gdoc_file_path; |
| if (!file_util::CreateTemporaryFileInDir( |
| cache->GetCacheDirectoryPath( |
| internal::FileCache::CACHE_TYPE_TMP_DOCUMENTS), |
| &gdoc_file_path) || |
| !util::CreateGDocFile(gdoc_file_path, |
| - GURL(entry.file_specific_info().alternate_url()), |
| - entry.resource_id())) |
| + GURL(entry->file_specific_info().alternate_url()), |
| + entry->resource_id())) |
| return FILE_ERROR_FAILED; |
| *cache_file_path = gdoc_file_path; |
| @@ -69,9 +69,28 @@ FileError CheckPreConditionForEnsureFileDownloaded( |
| } |
| // Get the cache file path if available. |
| - cache->GetFile(entry.resource_id(), |
| - entry.file_specific_info().file_md5(), |
| + cache->GetFile(entry->resource_id(), |
| + entry->file_specific_info().file_md5(), |
| cache_file_path); |
| + |
| + // If the cache file is available and dirty, the modified file info needs to |
| + // be stored in |entry|. |
|
hashimoto
2013/06/03 10:33:27
nit: Could you make a note about the fact that thi
kinaba
2013/06/04 03:30:17
Done.
|
| + if (!cache_file_path->empty()) { |
| + FileCacheEntry cache_entry; |
| + if (cache->GetCacheEntry(entry->resource_id(), |
| + entry->file_specific_info().file_md5(), |
| + &cache_entry) && |
| + cache_entry.is_dirty()) { |
| + base::PlatformFileInfo file_info; |
| + if (file_util::GetFileInfo(*cache_file_path, &file_info)) { |
| + PlatformFileInfoProto entry_file_info; |
| + util::ConvertPlatformFileInfoToResourceEntry(file_info, |
| + &entry_file_info); |
| + *entry->mutable_file_info() = entry_file_info; |
| + } |
| + } |
| + } |
| + |
| return FILE_ERROR_OK; |
| } |
| @@ -87,7 +106,7 @@ FileError CheckPreConditionForEnsureFileDownloadedByResourceId( |
| if (error != FILE_ERROR_OK) |
| return error; |
| return CheckPreConditionForEnsureFileDownloaded( |
| - metadata, cache, *entry, cache_file_path); |
| + metadata, cache, entry, cache_file_path); |
| } |
| // Calls CheckPreConditionForEnsureFileDownloaded() with the entry specified by |
| @@ -102,7 +121,7 @@ FileError CheckPreConditionForEnsureFileDownloadedByPath( |
| if (error != FILE_ERROR_OK) |
| return error; |
| return CheckPreConditionForEnsureFileDownloaded( |
| - metadata, cache, *entry, cache_file_path); |
| + metadata, cache, entry, cache_file_path); |
| } |
| // Creates a file with unique name in |dir| and stores the path to |temp_file|. |