summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-16 12:51:59 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-16 12:51:59 +0000
commit89572fe97def48ebb0aa2afc5822a36a55b98735 (patch)
tree15d49529e583bae53e7ae2c1d318668da6724171
parent2d76cd1297cb9c08ec51fafe549add333b6c1aa0 (diff)
downloadchromium_src-89572fe97def48ebb0aa2afc5822a36a55b98735.zip
chromium_src-89572fe97def48ebb0aa2afc5822a36a55b98735.tar.gz
chromium_src-89572fe97def48ebb0aa2afc5822a36a55b98735.tar.bz2
drive: Remove outgoing FileCache directory.
Stop dealing with symlinks from FileCache. Remove FileCache::CommitDirty because what it does is only manipulating symlinks. Treat all dirty files as committed when scanning files on DB corruption. BUG=134957 TEST=unit_tests Review URL: https://chromiumcodereview.appspot.com/14897007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200518 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/drive/file_cache.cc114
-rw-r--r--chrome/browser/chromeos/drive/file_cache.h6
-rw-r--r--chrome/browser/chromeos/drive/file_cache_metadata.cc126
-rw-r--r--chrome/browser/chromeos/drive/file_cache_metadata_unittest.cc60
-rw-r--r--chrome/browser/chromeos/drive/file_cache_unittest.cc57
5 files changed, 36 insertions, 327 deletions
diff --git a/chrome/browser/chromeos/drive/file_cache.cc b/chrome/browser/chromeos/drive/file_cache.cc
index 094ea78e..4541952 100644
--- a/chrome/browser/chromeos/drive/file_cache.cc
+++ b/chrome/browser/chromeos/drive/file_cache.cc
@@ -27,8 +27,6 @@ namespace internal {
namespace {
const base::FilePath::CharType kFileCacheMetaDir[] = FILE_PATH_LITERAL("meta");
-const base::FilePath::CharType kFileCacheOutgoingDir[] =
- FILE_PATH_LITERAL("outgoing");
const base::FilePath::CharType kFileCachePersistentDir[] =
FILE_PATH_LITERAL("persistent");
const base::FilePath::CharType kFileCacheTmpDir[] = FILE_PATH_LITERAL("tmp");
@@ -75,29 +73,6 @@ void RemoveAllFiles(const base::FilePath& directory) {
}
}
-// Deletes the symlink.
-void DeleteSymlink(const base::FilePath& symlink_path) {
- // We try to save one file operation by not checking if link exists before
- // deleting it, so unlink may return error if link doesn't exist, but it
- // doesn't really matter to us.
- file_util::Delete(symlink_path, false);
-}
-
-// Creates a symlink.
-bool CreateSymlink(const base::FilePath& cache_file_path,
- const base::FilePath& symlink_path) {
- // Remove symlink because creating a link will not overwrite an existing one.
- DeleteSymlink(symlink_path);
-
- // Create new symlink to |cache_file_path|.
- if (!file_util::CreateSymbolicLink(cache_file_path, symlink_path)) {
- LOG(ERROR) << "Failed to create a symlink from " << symlink_path.value()
- << " to " << cache_file_path.value();
- return false;
- }
- return true;
-}
-
// Moves the file.
bool MoveFile(const base::FilePath& source_path,
const base::FilePath& dest_path) {
@@ -435,13 +410,13 @@ void FileCache::CommitDirtyOnUIThread(const std::string& resource_id,
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
- base::PostTaskAndReplyWithResult(
- blocking_task_runner_,
+ // TODO(hashimoto): Move logic around OnCommitDirty to FileSystem and remove
+ // this method.
+ base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
- base::Bind(&FileCache::CommitDirty,
- base::Unretained(this), resource_id, md5),
base::Bind(&FileCache::OnCommitDirty,
- weak_ptr_factory_.GetWeakPtr(), resource_id, callback));
+ weak_ptr_factory_.GetWeakPtr(), resource_id, callback,
+ FILE_ERROR_OK));
}
void FileCache::ClearDirtyOnUIThread(const std::string& resource_id,
@@ -677,10 +652,6 @@ FileError FileCache::Store(const std::string& resource_id,
cache_entry.set_is_persistent(sub_dir_type == CACHE_TYPE_PERSISTENT);
cache_entry.set_is_dirty(origin == CACHED_FILE_LOCALLY_MODIFIED);
metadata_->AddOrUpdateCacheEntry(resource_id, cache_entry);
-
- // If storing a local modification, commit it.
- if (origin == CACHED_FILE_LOCALLY_MODIFIED)
- CommitDirty(resource_id, md5);
}
return success ? FILE_ERROR_OK : FILE_ERROR_FAILED;
@@ -899,23 +870,9 @@ FileError FileCache::MarkDirty(const std::string& resource_id,
return FILE_ERROR_NOT_FOUND;
}
- // If a file is already dirty (i.e. MarkDirtyInCache was called before),
- // delete outgoing symlink if it exists.
- // TODO(benchan): We should only delete outgoing symlink if file is currently
- // not being uploaded. However, for now, cache doesn't know if uploading of a
- // file is in progress. Per zel, the upload process should be canceled before
- // MarkDirtyInCache is called again.
if (cache_entry.is_dirty()) {
// The file must be in persistent dir.
DCHECK(cache_entry.is_persistent());
-
- // Determine symlink path in outgoing dir, so as to remove it.
- base::FilePath symlink_path = GetCacheFilePath(resource_id,
- std::string(),
- CACHE_TYPE_OUTGOING,
- CACHED_FILE_FROM_SERVER);
- DeleteSymlink(symlink_path);
-
return FILE_ERROR_OK;
}
@@ -946,55 +903,6 @@ FileError FileCache::MarkDirty(const std::string& resource_id,
return FILE_ERROR_OK;
}
-FileError FileCache::CommitDirty(const std::string& resource_id,
- const std::string& md5) {
- AssertOnSequencedWorkerPool();
-
- // If file has already been marked dirty in previous instance of chrome, we
- // would have lost the md5 info during cache initialization, because the file
- // would have been renamed to .local extension.
- // So, search for entry in cache without comparing md5.
-
- // Committing a file dirty means its entry and actual file blob must exist in
- // cache.
- FileCacheEntry cache_entry;
- if (!GetCacheEntry(resource_id, std::string(), &cache_entry) ||
- !cache_entry.is_present()) {
- LOG(WARNING) << "Can't commit dirty a file that wasn't cached: res_id="
- << resource_id
- << ", md5=" << md5;
- return FILE_ERROR_NOT_FOUND;
- }
-
- // If a file is not dirty (it should have been marked dirty via
- // MarkDirtyInCache), committing it dirty is an invalid operation.
- if (!cache_entry.is_dirty()) {
- LOG(WARNING) << "Can't commit a non-dirty file: res_id="
- << resource_id
- << ", md5=" << md5;
- return FILE_ERROR_INVALID_OPERATION;
- }
-
- // Dirty files must be in persistent dir.
- DCHECK(cache_entry.is_persistent());
-
- // Create symlink in outgoing dir.
- base::FilePath symlink_path = GetCacheFilePath(resource_id,
- std::string(),
- CACHE_TYPE_OUTGOING,
- CACHED_FILE_FROM_SERVER);
-
- // Get target path of symlink i.e. current path of the file in cache.
- base::FilePath target_path = GetCacheFilePath(
- resource_id,
- md5,
- GetSubDirectoryType(cache_entry),
- CACHED_FILE_LOCALLY_MODIFIED);
-
- return CreateSymlink(target_path, symlink_path) ?
- FILE_ERROR_OK : FILE_ERROR_FAILED;
-}
-
FileError FileCache::ClearDirty(const std::string& resource_id,
const std::string& md5) {
AssertOnSequencedWorkerPool();
@@ -1045,13 +953,6 @@ FileError FileCache::ClearDirty(const std::string& resource_id,
if (!MoveFile(source_path, dest_path))
return FILE_ERROR_FAILED;
- // Delete symlink in outgoing dir.
- base::FilePath symlink_path = GetCacheFilePath(resource_id,
- std::string(),
- CACHE_TYPE_OUTGOING,
- CACHED_FILE_FROM_SERVER);
- DeleteSymlink(symlink_path);
-
// Now that file operations have completed, update metadata.
cache_entry.set_md5(md5);
cache_entry.set_is_dirty(false);
@@ -1095,9 +996,7 @@ FileError FileCache::Remove(const std::string& resource_id) {
CACHE_TYPE_TMP,
CACHED_FILE_FROM_SERVER));
- // Don't delete locally modified (i.e. dirty and possibly outgoing) files.
- // Since we're not deleting outgoing symlinks, we don't need to append
- // outgoing path to |paths_to_delete|.
+ // Don't delete locally modified files.
base::FilePath path_to_keep = GetCacheFilePath(resource_id,
std::string(),
CACHE_TYPE_PERSISTENT,
@@ -1199,7 +1098,6 @@ std::vector<base::FilePath> FileCache::GetCachePaths(
std::vector<base::FilePath> cache_paths;
// The order should match FileCache::CacheSubDirectoryType enum.
cache_paths.push_back(cache_root_path.Append(kFileCacheMetaDir));
- cache_paths.push_back(cache_root_path.Append(kFileCacheOutgoingDir));
cache_paths.push_back(cache_root_path.Append(kFileCachePersistentDir));
cache_paths.push_back(cache_root_path.Append(kFileCacheTmpDir));
cache_paths.push_back(cache_root_path.Append(kFileCacheTmpDownloadsDir));
diff --git a/chrome/browser/chromeos/drive/file_cache.h b/chrome/browser/chromeos/drive/file_cache.h
index f7c2bb3..fce93f1 100644
--- a/chrome/browser/chromeos/drive/file_cache.h
+++ b/chrome/browser/chromeos/drive/file_cache.h
@@ -69,8 +69,6 @@ class FileCache {
// This indexes into |FileCache::cache_paths_| vector.
enum CacheSubDirectoryType {
CACHE_TYPE_META = 0, // Downloaded feeds.
- CACHE_TYPE_OUTGOING, // Symlinks to files in persistent or tmp dir to
- // be uploaded.
CACHE_TYPE_PERSISTENT, // Files that are pinned or modified locally,
// not evictable, hopefully.
CACHE_TYPE_TMP, // Files that don't meet criteria to be in
@@ -363,10 +361,6 @@ class FileCache {
FileError MarkDirty(const std::string& resource_id,
const std::string& md5);
- // Used to implement CommitDirtyOnUIThread.
- FileError CommitDirty(const std::string& resource_id,
- const std::string& md5);
-
// Used to implement ClearDirtyOnUIThread.
FileError ClearDirty(const std::string& resource_id,
const std::string& md5);
diff --git a/chrome/browser/chromeos/drive/file_cache_metadata.cc b/chrome/browser/chromeos/drive/file_cache_metadata.cc
index ae40aed..e6ffb3d 100644
--- a/chrome/browser/chromeos/drive/file_cache_metadata.cc
+++ b/chrome/browser/chromeos/drive/file_cache_metadata.cc
@@ -29,34 +29,6 @@ enum DBOpenStatus {
// A map table of resource ID to file path.
typedef std::map<std::string, base::FilePath> ResourceIdToFilePathMap;
-// Returns true if |file_path| is a valid symbolic link as |sub_dir_type|.
-// Otherwise, returns false with the reason.
-bool IsValidSymbolicLink(const base::FilePath& file_path,
- FileCache::CacheSubDirectoryType sub_dir_type,
- const std::vector<base::FilePath>& cache_paths,
- std::string* reason) {
- DCHECK_EQ(FileCache::CACHE_TYPE_OUTGOING, sub_dir_type);
-
- base::FilePath destination;
- if (!file_util::ReadSymbolicLink(file_path, &destination)) {
- *reason = "failed to read the symlink (maybe not a symlink)";
- return false;
- }
-
- if (!file_util::PathExists(destination)) {
- *reason = "pointing to a non-existent file";
- return false;
- }
-
- // The destination file should be in the persistent directory.
- if (!cache_paths[FileCache::CACHE_TYPE_PERSISTENT].IsParent(destination)) {
- *reason = "pointing to a file outside of persistent directory";
- return false;
- }
-
- return true;
-}
-
// Scans cache subdirectory and build or update |cache_map|
// with found file blobs or symlinks.
//
@@ -87,65 +59,31 @@ void ScanCacheDirectory(
// Determine cache state.
FileCacheEntry cache_entry;
cache_entry.set_md5(md5);
- if (sub_dir_type == FileCache::CACHE_TYPE_OUTGOING) {
- std::string reason;
- if (!IsValidSymbolicLink(current, sub_dir_type, cache_paths, &reason)) {
- LOG(WARNING) << "Removing an invalid symlink: " << current.value()
- << ": " << reason;
- file_util::Delete(current, false);
- continue;
- }
-
- // If we're scanning outgoing directory, entry must exist and be dirty.
- // Otherwise, it's a logic error from previous execution, remove this
- // outgoing symlink and move on.
- FileCacheMetadata::CacheMap::iterator iter =
- cache_map->find(resource_id);
- if (iter == cache_map->end() || !iter->second.is_dirty()) {
- LOG(WARNING) << "Removing an symlink to a non-dirty file: "
- << current.value();
- file_util::Delete(current, false);
- continue;
- }
-
- processed_file_map->insert(std::make_pair(resource_id, current));
- continue;
- } else if (sub_dir_type == FileCache::CACHE_TYPE_PERSISTENT ||
- sub_dir_type == FileCache::CACHE_TYPE_TMP) {
- if (sub_dir_type == FileCache::CACHE_TYPE_PERSISTENT)
- cache_entry.set_is_persistent(true);
-
- if (file_util::IsLink(current)) {
- LOG(WARNING) << "Removing a symlink in persistent/tmp directory"
- << current.value();
- file_util::Delete(current, false);
- continue;
- }
- if (extra_extension == util::kMountedArchiveFileExtension) {
- // Mounted archives in cache should be unmounted upon logout/shutdown.
- // But if we encounter a mounted file at start, delete it and create an
- // entry with not PRESENT state.
- DCHECK(sub_dir_type == FileCache::CACHE_TYPE_PERSISTENT);
- file_util::Delete(current, false);
- } else {
- // The cache file is present.
- cache_entry.set_is_present(true);
-
- // Adds the dirty bit if |md5| indicates that the file is dirty, and
- // the file is in the persistent directory.
- if (md5 == util::kLocallyModifiedFileExtension) {
- if (sub_dir_type == FileCache::CACHE_TYPE_PERSISTENT) {
- cache_entry.set_is_dirty(true);
- } else {
- LOG(WARNING) << "Removing a dirty file in tmp directory: "
- << current.value();
- file_util::Delete(current, false);
- continue;
- }
+ if (sub_dir_type == FileCache::CACHE_TYPE_PERSISTENT)
+ cache_entry.set_is_persistent(true);
+
+ if (extra_extension == util::kMountedArchiveFileExtension) {
+ // Mounted archives in cache should be unmounted upon logout/shutdown.
+ // But if we encounter a mounted file at start, delete it and create an
+ // entry with not PRESENT state.
+ DCHECK(sub_dir_type == FileCache::CACHE_TYPE_PERSISTENT);
+ file_util::Delete(current, false);
+ } else {
+ // The cache file is present.
+ cache_entry.set_is_present(true);
+
+ // Adds the dirty bit if |md5| indicates that the file is dirty, and
+ // the file is in the persistent directory.
+ if (md5 == util::kLocallyModifiedFileExtension) {
+ if (sub_dir_type == FileCache::CACHE_TYPE_PERSISTENT) {
+ cache_entry.set_is_dirty(true);
+ } else {
+ LOG(WARNING) << "Removing a dirty file in tmp directory: "
+ << current.value();
+ file_util::Delete(current, false);
+ continue;
}
}
- } else {
- NOTREACHED() << "Unexpected sub directory type: " << sub_dir_type;
}
// Create and insert new entry into cache map.
@@ -171,14 +109,6 @@ void ScanCachePaths(const std::vector<base::FilePath>& cache_paths,
cache_map,
&tmp_file_map);
- // Then scan outgoing directory to check if dirty-files are committed
- // properly (i.e. symlinks created in outgoing directory).
- ResourceIdToFilePathMap outgoing_file_map;
- ScanCacheDirectory(cache_paths,
- FileCache::CACHE_TYPE_OUTGOING,
- cache_map,
- &outgoing_file_map);
-
// On DB corruption, keep only dirty-and-committed files in persistent
// directory. Other files are deleted or moved to temporary directory.
for (ResourceIdToFilePathMap::const_iterator iter =
@@ -192,9 +122,8 @@ void ScanCachePaths(const std::vector<base::FilePath>& cache_paths,
if (cache_map_iter != cache_map->end()) {
FileCacheEntry* cache_entry = &cache_map_iter->second;
const bool is_dirty = cache_entry->is_dirty();
- const bool is_committed = outgoing_file_map.count(resource_id) != 0;
- if (!is_dirty && !is_committed) {
- // If the file is not dirty nor committed, move to temporary directory.
+ if (!is_dirty) {
+ // If the file is not dirty, move to temporary directory.
base::FilePath new_file_path =
cache_paths[FileCache::CACHE_TYPE_TMP].Append(
file_path.BaseName());
@@ -202,11 +131,6 @@ void ScanCachePaths(const std::vector<base::FilePath>& cache_paths,
<< " to: " << new_file_path.value();
file_util::Move(file_path, new_file_path);
cache_entry->set_is_persistent(false);
- } else if (!is_dirty || !is_committed) {
- // If the file is not dirty-and-committed, remove it.
- DLOG(WARNING) << "Removing: " << file_path.value();
- file_util::Delete(file_path, false);
- cache_map->erase(cache_map_iter);
}
}
}
diff --git a/chrome/browser/chromeos/drive/file_cache_metadata_unittest.cc b/chrome/browser/chromeos/drive/file_cache_metadata_unittest.cc
index c121d91..8d8ef25 100644
--- a/chrome/browser/chromeos/drive/file_cache_metadata_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_cache_metadata_unittest.cc
@@ -28,7 +28,6 @@ class FileCacheMetadataTest : public testing::Test {
persistent_directory_ = cache_paths_[FileCache::CACHE_TYPE_PERSISTENT];
tmp_directory_ = cache_paths_[FileCache::CACHE_TYPE_TMP];
- outgoing_directory_ = cache_paths_[FileCache::CACHE_TYPE_OUTGOING];
}
virtual void TearDown() OVERRIDE {
@@ -41,39 +40,19 @@ class FileCacheMetadataTest : public testing::Test {
ASSERT_TRUE(metadata_->Initialize(cache_paths_));
}
- // Sets up the cache directories with various files, including stale
- // symbolic links etc. Should be called before SetUpCacheMetadata().
+ // Sets up the cache directories with various files.
+ // Should be called before SetUpCacheMetadata().
void SetUpCacheWithVariousFiles() {
// Create some files in persistent directory.
//
CreateFile(persistent_directory_.AppendASCII("id_foo.md5foo"));
CreateFile(persistent_directory_.AppendASCII("id_bar.local"));
- // "id_baz" is dirty but does not have a symlink in outgoing
- // directory. This file should be removed.
- CreateFile(persistent_directory_.AppendASCII("id_baz.local"));
- // "id_symlink" is invalid, as symlink is not allowed here. This should
- // be removed.
- CreateSymbolicLink(base::FilePath::FromUTF8Unsafe(util::kSymLinkToDevNull),
- persistent_directory_.AppendASCII("id_symlink"));
// Create some files in tmp directory.
//
CreateFile(tmp_directory_.AppendASCII("id_qux.md5qux"));
// "id_quux" is invalid as we shouldn't have a dirty file in "tmp".
CreateFile(tmp_directory_.AppendASCII("id_quux.local"));
- // "id_symlink_tmp" is invalid, as symlink is not allowed here. This
- // should be removed.
- CreateSymbolicLink(base::FilePath::FromUTF8Unsafe(util::kSymLinkToDevNull),
- tmp_directory_.AppendASCII("id_symlink_tmp"));
-
- // Create symbolic links in outgoing directory.
- //
- // "id_bar" is dirty and committed.
- CreateSymbolicLink(persistent_directory_.AppendASCII("id_bar.local"),
- outgoing_directory_.AppendASCII("id_bar"));
- // "id_foo" is not dirty. This symlink should be removed.
- CreateSymbolicLink(persistent_directory_.AppendASCII("id_foo.md5foo"),
- outgoing_directory_.AppendASCII("id_foo"));
}
// Create a file at |file_path|.
@@ -83,13 +62,6 @@ class FileCacheMetadataTest : public testing::Test {
<< ": " << file_path.value();
}
- // Create an symlink to |target| at |symlink|.
- void CreateSymbolicLink(const base::FilePath& target,
- const base::FilePath& symlink) {
- ASSERT_TRUE(file_util::CreateSymbolicLink(target, symlink))
- << ": " << target.value() << ": " << symlink.value();
- }
-
protected:
// Helper function to insert an item with key |resource_id| into |cache_map|.
// |md5| and |cache_state| are used to create the value FileCacheEntry.
@@ -113,7 +85,6 @@ class FileCacheMetadataTest : public testing::Test {
std::vector<base::FilePath> cache_paths_;
base::FilePath persistent_directory_;
base::FilePath tmp_directory_;
- base::FilePath outgoing_directory_;
};
// Test all the methods of FileCacheMetadata except for
@@ -222,7 +193,6 @@ TEST_F(FileCacheMetadataTest, CacheTest) {
TEST_F(FileCacheMetadataTest, CorruptDB) {
using file_util::PathExists;
- using file_util::IsLink;
SetUpCacheWithVariousFiles();
const base::FilePath db_path =
@@ -235,10 +205,7 @@ TEST_F(FileCacheMetadataTest, CorruptDB) {
// Some files are removed during cache initialization. Make sure these
// exist beforehand.
- EXPECT_TRUE(PathExists(persistent_directory_.AppendASCII("id_baz.local")));
EXPECT_TRUE(PathExists(tmp_directory_.AppendASCII("id_quux.local")));
- EXPECT_TRUE(IsLink(persistent_directory_.AppendASCII("id_symlink")));
- EXPECT_TRUE(IsLink(tmp_directory_.AppendASCII("id_symlink_tmp")));
SetUpCacheMetadata();
@@ -253,8 +220,6 @@ TEST_F(FileCacheMetadataTest, CorruptDB) {
test_util::ToCacheEntry(test_util::TEST_CACHE_STATE_PRESENT),
cache_entry));
EXPECT_TRUE(PathExists(tmp_directory_.AppendASCII("id_foo.md5foo")));
- // The invalid symlink in "outgoing" should be removed.
- EXPECT_FALSE(PathExists(outgoing_directory_.AppendASCII("id_foo")));
// "id_bar" is present and dirty.
ASSERT_TRUE(metadata_->GetCacheEntry("id_bar", "", &cache_entry));
@@ -267,15 +232,6 @@ TEST_F(FileCacheMetadataTest, CorruptDB) {
test_util::TEST_CACHE_STATE_PERSISTENT),
cache_entry));
EXPECT_TRUE(PathExists(persistent_directory_.AppendASCII("id_bar.local")));
- EXPECT_TRUE(PathExists(outgoing_directory_.AppendASCII("id_bar")));
-
- // "id_baz" should be removed during cache initialization.
- EXPECT_FALSE(metadata_->GetCacheEntry("id_baz", "", &cache_entry));
- EXPECT_FALSE(PathExists(persistent_directory_.AppendASCII("id_baz.local")));
-
- // "id_symlink" should be removed during cache initialization.
- EXPECT_FALSE(metadata_->GetCacheEntry("id_symlink", "", &cache_entry));
- EXPECT_FALSE(PathExists(persistent_directory_.AppendASCII("id_symlink")));
// Check contents in "tmp" directory.
//
@@ -291,18 +247,6 @@ TEST_F(FileCacheMetadataTest, CorruptDB) {
// "id_quux" should be removed during cache initialization.
EXPECT_FALSE(metadata_->GetCacheEntry("id_quux", "md5qux", &cache_entry));
-
- // "id_symlink_tmp" should be removed during cache initialization.
- EXPECT_FALSE(metadata_->GetCacheEntry("id_symlink_tmp", "", &cache_entry));
-
- // "id_dangling" should be removed during cache initialization.
- EXPECT_FALSE(metadata_->GetCacheEntry("id_dangling", "", &cache_entry));
-
- // "id_outside" should be removed during cache initialization.
- EXPECT_FALSE(metadata_->GetCacheEntry("id_outside", "", &cache_entry));
-
- // "id_not_symlink" should be removed during cache initialization.
- EXPECT_FALSE(metadata_->GetCacheEntry("id_not_symlink", "", &cache_entry));
}
// Test FileCacheMetadata::RemoveTemporaryFiles.
diff --git a/chrome/browser/chromeos/drive/file_cache_unittest.cc b/chrome/browser/chromeos/drive/file_cache_unittest.cc
index 773a69d..13c1276 100644
--- a/chrome/browser/chromeos/drive/file_cache_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_cache_unittest.cc
@@ -90,8 +90,7 @@ class FileCacheTest : public testing::Test {
expected_error_(FILE_ERROR_OK),
expected_cache_state_(0),
expected_sub_dir_type_(FileCache::CACHE_TYPE_META),
- expected_success_(true),
- expect_outgoing_symlink_(false) {
+ expected_success_(true) {
}
virtual void SetUp() OVERRIDE {
@@ -228,12 +227,10 @@ class FileCacheTest : public testing::Test {
const base::FilePath& source_path,
FileError expected_error,
int expected_cache_state,
- FileCache::CacheSubDirectoryType expected_sub_dir_type,
- bool expected_outgoing_symlink) {
+ FileCache::CacheSubDirectoryType expected_sub_dir_type) {
expected_error_ = expected_error;
expected_cache_state_ = expected_cache_state;
expected_sub_dir_type_ = expected_sub_dir_type;
- expect_outgoing_symlink_ = expected_outgoing_symlink;
FileError error = FILE_ERROR_OK;
cache_->StoreLocallyModifiedOnUIThread(
@@ -280,10 +277,6 @@ class FileCacheTest : public testing::Test {
PathToVerify(cache_->GetCacheFilePath(resource_id, "*",
FileCache::CACHE_TYPE_PERSISTENT,
FileCache::CACHED_FILE_FROM_SERVER), base::FilePath()));
- paths_to_verify.push_back( // Index 2: CACHE_TYPE_OUTGOING.
- PathToVerify(cache_->GetCacheFilePath(resource_id, "",
- FileCache::CACHE_TYPE_OUTGOING,
- FileCache::CACHED_FILE_FROM_SERVER), base::FilePath()));
if (!cache_entry_found) {
for (size_t i = 0; i < paths_to_verify.size(); ++i) {
file_util::FileEnumerator enumerator(
@@ -297,7 +290,6 @@ class FileCacheTest : public testing::Test {
// Entry is dirty, verify that:
// - no files with "<resource_id>.*" exist in tmp dir
// - only 1 "<resource_id>.local" exists in persistent dir
- // - only 1 <resource_id> exists in outgoing dir
// - if entry is pinned, only 1 <resource_id> exists in pinned dir.
// Change expected_existing_path of CACHE_TYPE_PERSISTENT (index 1).
@@ -307,13 +299,6 @@ class FileCacheTest : public testing::Test {
FileCache::CACHE_TYPE_PERSISTENT,
FileCache::CACHED_FILE_LOCALLY_MODIFIED);
- // Change expected_existing_path of CACHE_TYPE_OUTGOING (index 2).
- paths_to_verify[2].expected_existing_path =
- GetCacheFilePath(resource_id,
- std::string(),
- FileCache::CACHE_TYPE_OUTGOING,
- FileCache::CACHED_FILE_FROM_SERVER);
-
for (size_t i = 0; i < paths_to_verify.size(); ++i) {
const struct PathToVerify& verify = paths_to_verify[i];
file_util::FileEnumerator enumerator(
@@ -379,7 +364,6 @@ class FileCacheTest : public testing::Test {
expected_error_ = expected_error;
expected_cache_state_ = expected_cache_state;
expected_sub_dir_type_ = expected_sub_dir_type;
- expect_outgoing_symlink_ = false;
FileError error = FILE_ERROR_OK;
cache_->MarkDirtyOnUIThread(
@@ -416,7 +400,6 @@ class FileCacheTest : public testing::Test {
expected_error_ = expected_error;
expected_cache_state_ = expected_cache_state;
expected_sub_dir_type_ = expected_sub_dir_type;
- expect_outgoing_symlink_ = true;
FileError error = FILE_ERROR_OK;
cache_->CommitDirtyOnUIThread(
@@ -435,7 +418,6 @@ class FileCacheTest : public testing::Test {
expected_error_ = expected_error;
expected_cache_state_ = expected_cache_state;
expected_sub_dir_type_ = expected_sub_dir_type;
- expect_outgoing_symlink_ = false;
FileError error = FILE_ERROR_OK;
cache_->ClearDirtyOnUIThread(
@@ -454,7 +436,6 @@ class FileCacheTest : public testing::Test {
expected_error_ = expected_error;
expected_cache_state_ = expected_cache_state;
expected_sub_dir_type_ = expected_sub_dir_type;
- expect_outgoing_symlink_ = false;
FileError error = FILE_ERROR_OK;
base::FilePath cache_file_path;
@@ -482,7 +463,6 @@ class FileCacheTest : public testing::Test {
expected_error_ = expected_error;
expected_cache_state_ = expected_cache_state;
expected_sub_dir_type_ = expected_sub_dir_type;
- expect_outgoing_symlink_ = false;
FileError error = FILE_ERROR_OK;
cache_->MarkAsUnmountedOnUIThread(
@@ -543,26 +523,6 @@ class FileCacheTest : public testing::Test {
EXPECT_TRUE(exists);
else
EXPECT_FALSE(exists);
-
- // Verify symlink in outgoing dir.
- base::FilePath symlink_path = cache_->GetCacheFilePath(
- resource_id,
- std::string(),
- FileCache::CACHE_TYPE_OUTGOING,
- FileCache::CACHED_FILE_FROM_SERVER);
- // Check that outgoing symlink exists, without dereferencing to target path.
- exists = file_util::IsLink(symlink_path);
- if (expect_outgoing_symlink_ &&
- test_util::ToCacheEntry(expected_cache_state_).is_dirty()) {
- EXPECT_TRUE(exists);
- base::FilePath target_path;
- EXPECT_TRUE(file_util::ReadSymbolicLink(symlink_path, &target_path));
- EXPECT_NE(util::kSymLinkToDevNull, target_path.value());
- if (test_util::ToCacheEntry(expected_cache_state_).is_present())
- EXPECT_EQ(dest_path, target_path);
- } else {
- EXPECT_FALSE(exists);
- }
}
base::FilePath GetCacheFilePath(const std::string& resource_id,
@@ -655,7 +615,6 @@ class FileCacheTest : public testing::Test {
int expected_cache_state_;
FileCache::CacheSubDirectoryType expected_sub_dir_type_;
bool expected_success_;
- bool expect_outgoing_symlink_;
std::string expected_file_extension_;
};
@@ -725,7 +684,7 @@ TEST_F(FileCacheTest, LocallyModifiedSimple) {
TestStoreLocallyModifiedToCache(
resource_id, md5,
google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"),
- FILE_ERROR_OK, kDirtyCacheState, FileCache::CACHE_TYPE_PERSISTENT, true);
+ FILE_ERROR_OK, kDirtyCacheState, FileCache::CACHE_TYPE_PERSISTENT);
}
TEST_F(FileCacheTest, GetFromCacheSimple) {
@@ -1161,11 +1120,6 @@ TEST_F(FileCacheTest, DirtyCacheInvalid) {
test_util::TEST_CACHE_STATE_NONE,
FileCache::CACHE_TYPE_TMP);
- // Commit a non-existent file dirty.
- TestCommitDirty(resource_id, md5, FILE_ERROR_NOT_FOUND,
- test_util::TEST_CACHE_STATE_NONE,
- FileCache::CACHE_TYPE_TMP);
-
// Clear dirty state of a non-existent file.
TestClearDirty(resource_id, md5, FILE_ERROR_NOT_FOUND,
test_util::TEST_CACHE_STATE_NONE,
@@ -1178,11 +1132,6 @@ TEST_F(FileCacheTest, DirtyCacheInvalid) {
FILE_ERROR_OK, test_util::TEST_CACHE_STATE_PRESENT,
FileCache::CACHE_TYPE_TMP);
- // Commit a non-dirty existing file dirty.
- TestCommitDirty(resource_id, md5, FILE_ERROR_INVALID_OPERATION,
- test_util::TEST_CACHE_STATE_PRESENT,
- FileCache::CACHE_TYPE_TMP);
-
// Clear dirty state of a non-dirty existing file.
TestClearDirty(resource_id, md5, FILE_ERROR_INVALID_OPERATION,
test_util::TEST_CACHE_STATE_PRESENT,