Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / drive / file_cache.cc
index 9bdd09b..c387cdd 100644 (file)
@@ -150,11 +150,8 @@ FileError FileCache::Store(const std::string& id,
   if (!FreeDiskSpaceIfNeededFor(file_size))
     return FILE_ERROR_NO_LOCAL_SPACE;
 
-  FileCacheEntry cache_entry;
-  storage_->GetCacheEntry(id, &cache_entry);
-
-  // If file is dirty or mounted, return error.
-  if (cache_entry.is_dirty() || mounted_files_.count(id))
+  // If file is mounted, return error.
+  if (mounted_files_.count(id))
     return FILE_ERROR_IN_USE;
 
   base::FilePath dest_path = GetCacheFilePath(id);
@@ -179,9 +176,12 @@ FileError FileCache::Store(const std::string& id,
   }
 
   // Now that file operations have completed, update metadata.
+  FileCacheEntry cache_entry;
+  storage_->GetCacheEntry(id, &cache_entry);
   cache_entry.set_md5(md5);
   cache_entry.set_is_present(true);
-  cache_entry.set_is_dirty(false);
+  if (md5.empty())
+    cache_entry.set_is_dirty(true);
   return storage_->PutCacheEntry(id, cache_entry) ?
       FILE_ERROR_OK : FILE_ERROR_FAILED;
 }