Index: chrome/browser/chromeos/drive/sync/entry_update_performer.cc |
diff --git a/chrome/browser/chromeos/drive/sync/entry_update_performer.cc b/chrome/browser/chromeos/drive/sync/entry_update_performer.cc |
index 9ca9139c18b30d8161f10b4c8db54fc2ce9c7d49..8a463c4af6dea939a42ed89d16b31e2720989808 100644 |
--- a/chrome/browser/chromeos/drive/sync/entry_update_performer.cc |
+++ b/chrome/browser/chromeos/drive/sync/entry_update_performer.cc |
@@ -9,6 +9,7 @@ |
#include "chrome/browser/chromeos/drive/change_list_loader.h" |
#include "chrome/browser/chromeos/drive/drive.pb.h" |
#include "chrome/browser/chromeos/drive/file_cache.h" |
+#include "chrome/browser/chromeos/drive/file_change.h" |
#include "chrome/browser/chromeos/drive/file_system/operation_observer.h" |
#include "chrome/browser/chromeos/drive/file_system_util.h" |
#include "chrome/browser/chromeos/drive/job_scheduler.h" |
@@ -119,15 +120,20 @@ FileError FinishUpdate(ResourceMetadata* metadata, |
FileCache* cache, |
const std::string& local_id, |
scoped_ptr<google_apis::FileResource> file_resource, |
- base::FilePath* changed_directory) { |
+ FileChange* changed_files) { |
// When creating new entries, update check may add a new entry with the same |
// resource ID before us. If such an entry exists, remove it. |
std::string existing_local_id; |
FileError error = metadata->GetIdByResourceId( |
file_resource->file_id(), &existing_local_id); |
kinaba
2014/06/23 05:37:43
The |error| value for this call must be checked in
yoshiki
2014/06/24 02:02:22
Done.
|
+ ResourceEntry entry; |
+ error = metadata->GetResourceEntryById(local_id, &entry); |
+ if (error != FILE_ERROR_OK) |
+ return error; |
+ |
switch (error) { |
case FILE_ERROR_OK: |
- if (existing_local_id != local_id) { |
+ if (existing_local_id != local_id && !existing_local_id.empty()) { |
kinaba
2014/06/23 05:37:43
and if the above |error| is properly checked, exis
yoshiki
2014/06/24 02:02:22
Done.
|
base::FilePath existing_entry_path; |
error = metadata->GetFilePath(existing_local_id, &existing_entry_path); |
if (error != FILE_ERROR_OK) |
@@ -135,7 +141,7 @@ FileError FinishUpdate(ResourceMetadata* metadata, |
error = metadata->RemoveEntry(existing_local_id); |
if (error != FILE_ERROR_OK) |
return error; |
- *changed_directory = existing_entry_path.DirName(); |
+ changed_files->Update(existing_entry_path, entry, FileChange::DELETE); |
} |
break; |
case FILE_ERROR_NOT_FOUND: |
@@ -144,11 +150,6 @@ FileError FinishUpdate(ResourceMetadata* metadata, |
return error; |
} |
- ResourceEntry entry; |
- error = metadata->GetResourceEntryById(local_id, &entry); |
- if (error != FILE_ERROR_OK) |
- return error; |
- |
// Update metadata_edit_state and MD5. |
switch (entry.metadata_edit_state()) { |
case ResourceEntry::CLEAN: // Nothing to do. |
@@ -165,6 +166,11 @@ FileError FinishUpdate(ResourceMetadata* metadata, |
error = metadata->RefreshEntry(entry); |
if (error != FILE_ERROR_OK) |
return error; |
+ base::FilePath entry_path; |
+ error = metadata->GetFilePath(local_id, &entry_path); |
+ if (error != FILE_ERROR_OK) |
+ return error; |
+ changed_files->Update(entry_path, entry, FileChange::ADD_OR_UPDATE); |
// Clear dirty bit unless the file has been edited during update. |
if (entry.file_specific_info().cache_state().is_dirty() && |
@@ -369,27 +375,30 @@ void EntryUpdatePerformer::UpdateEntryAfterUpdateResource( |
return; |
} |
- base::FilePath* changed_directory = new base::FilePath; |
+ FileChange* changed_files = new FileChange; |
base::PostTaskAndReplyWithResult( |
blocking_task_runner_.get(), |
FROM_HERE, |
base::Bind(&FinishUpdate, |
- metadata_, cache_, local_id, base::Passed(&entry), |
- changed_directory), |
+ metadata_, |
+ cache_, |
+ local_id, |
+ base::Passed(&entry), |
+ changed_files), |
base::Bind(&EntryUpdatePerformer::UpdateEntryAfterFinish, |
- weak_ptr_factory_.GetWeakPtr(), callback, |
- base::Owned(changed_directory))); |
+ weak_ptr_factory_.GetWeakPtr(), |
+ callback, |
+ base::Owned(changed_files))); |
} |
void EntryUpdatePerformer::UpdateEntryAfterFinish( |
const FileOperationCallback& callback, |
- const base::FilePath* changed_directory, |
+ const FileChange* changed_files, |
FileError error) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
DCHECK(!callback.is_null()); |
- if (!changed_directory->empty()) |
- observer_->OnDirectoryChangedByOperation(*changed_directory); |
+ observer_->OnDirectoryChangedByOperation(*changed_files); |
callback.Run(error); |
} |