OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/fileapi/file_system_directory_database.h" | 5 #include "webkit/fileapi/file_system_directory_database.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <set> | 9 #include <set> |
10 #include <stack> | 10 #include <stack> |
(...skipping 15 matching lines...) Expand all Loading... |
26 const fileapi::FileSystemDirectoryDatabase::FileInfo& info, | 26 const fileapi::FileSystemDirectoryDatabase::FileInfo& info, |
27 Pickle* pickle) { | 27 Pickle* pickle) { |
28 DCHECK(pickle); | 28 DCHECK(pickle); |
29 std::string data_path; | 29 std::string data_path; |
30 // Round off here to match the behavior of the filesystem on real files. | 30 // Round off here to match the behavior of the filesystem on real files. |
31 base::Time time = | 31 base::Time time = |
32 base::Time::FromDoubleT(floor(info.modification_time.ToDoubleT())); | 32 base::Time::FromDoubleT(floor(info.modification_time.ToDoubleT())); |
33 std::string name; | 33 std::string name; |
34 | 34 |
35 data_path = fileapi::FilePathToString(info.data_path); | 35 data_path = fileapi::FilePathToString(info.data_path); |
36 name = fileapi::FilePathToString(FilePath(info.name)); | 36 name = fileapi::FilePathToString(base::FilePath(info.name)); |
37 | 37 |
38 if (pickle->WriteInt64(info.parent_id) && | 38 if (pickle->WriteInt64(info.parent_id) && |
39 pickle->WriteString(data_path) && | 39 pickle->WriteString(data_path) && |
40 pickle->WriteString(name) && | 40 pickle->WriteString(name) && |
41 pickle->WriteInt64(time.ToInternalValue())) | 41 pickle->WriteInt64(time.ToInternalValue())) |
42 return true; | 42 return true; |
43 | 43 |
44 NOTREACHED(); | 44 NOTREACHED(); |
45 return false; | 45 return false; |
46 } | 46 } |
(...skipping 12 matching lines...) Expand all Loading... |
59 pickle.ReadInt64(&iter, &internal_time)) { | 59 pickle.ReadInt64(&iter, &internal_time)) { |
60 info->data_path = fileapi::StringToFilePath(data_path); | 60 info->data_path = fileapi::StringToFilePath(data_path); |
61 info->name = fileapi::StringToFilePath(name).value(); | 61 info->name = fileapi::StringToFilePath(name).value(); |
62 info->modification_time = base::Time::FromInternalValue(internal_time); | 62 info->modification_time = base::Time::FromInternalValue(internal_time); |
63 return true; | 63 return true; |
64 } | 64 } |
65 LOG(ERROR) << "Pickle could not be digested!"; | 65 LOG(ERROR) << "Pickle could not be digested!"; |
66 return false; | 66 return false; |
67 } | 67 } |
68 | 68 |
69 const FilePath::CharType kDirectoryDatabaseName[] = FILE_PATH_LITERAL("Paths"); | 69 const base::FilePath::CharType kDirectoryDatabaseName[] = FILE_PATH_LITERAL("Pat
hs"); |
70 const char kChildLookupPrefix[] = "CHILD_OF:"; | 70 const char kChildLookupPrefix[] = "CHILD_OF:"; |
71 const char kChildLookupSeparator[] = ":"; | 71 const char kChildLookupSeparator[] = ":"; |
72 const char kLastFileIdKey[] = "LAST_FILE_ID"; | 72 const char kLastFileIdKey[] = "LAST_FILE_ID"; |
73 const char kLastIntegerKey[] = "LAST_INTEGER"; | 73 const char kLastIntegerKey[] = "LAST_INTEGER"; |
74 const int64 kMinimumReportIntervalHours = 1; | 74 const int64 kMinimumReportIntervalHours = 1; |
75 const char kInitStatusHistogramLabel[] = "FileSystem.DirectoryDatabaseInit"; | 75 const char kInitStatusHistogramLabel[] = "FileSystem.DirectoryDatabaseInit"; |
76 | 76 |
77 enum InitStatus { | 77 enum InitStatus { |
78 INIT_STATUS_OK = 0, | 78 INIT_STATUS_OK = 0, |
79 INIT_STATUS_CORRUPTION, | 79 INIT_STATUS_CORRUPTION, |
80 INIT_STATUS_IO_ERROR, | 80 INIT_STATUS_IO_ERROR, |
81 INIT_STATUS_UNKNOWN_ERROR, | 81 INIT_STATUS_UNKNOWN_ERROR, |
82 INIT_STATUS_MAX | 82 INIT_STATUS_MAX |
83 }; | 83 }; |
84 | 84 |
85 std::string GetChildLookupKey( | 85 std::string GetChildLookupKey( |
86 fileapi::FileSystemDirectoryDatabase::FileId parent_id, | 86 fileapi::FileSystemDirectoryDatabase::FileId parent_id, |
87 const FilePath::StringType& child_name) { | 87 const base::FilePath::StringType& child_name) { |
88 std::string name; | 88 std::string name; |
89 name = fileapi::FilePathToString(FilePath(child_name)); | 89 name = fileapi::FilePathToString(base::FilePath(child_name)); |
90 return std::string(kChildLookupPrefix) + base::Int64ToString(parent_id) + | 90 return std::string(kChildLookupPrefix) + base::Int64ToString(parent_id) + |
91 std::string(kChildLookupSeparator) + name; | 91 std::string(kChildLookupSeparator) + name; |
92 } | 92 } |
93 | 93 |
94 std::string GetChildListingKeyPrefix( | 94 std::string GetChildListingKeyPrefix( |
95 fileapi::FileSystemDirectoryDatabase::FileId parent_id) { | 95 fileapi::FileSystemDirectoryDatabase::FileId parent_id) { |
96 return std::string(kChildLookupPrefix) + base::Int64ToString(parent_id) + | 96 return std::string(kChildLookupPrefix) + base::Int64ToString(parent_id) + |
97 std::string(kChildLookupSeparator); | 97 std::string(kChildLookupSeparator); |
98 } | 98 } |
99 | 99 |
(...skipping 22 matching lines...) Expand all Loading... |
122 // - Each file in the database has unique backing file. | 122 // - Each file in the database has unique backing file. |
123 // - Each file in |filesystem_data_directory_| has a database entry. | 123 // - Each file in |filesystem_data_directory_| has a database entry. |
124 // - Directory structure is tree, i.e. connected and acyclic. | 124 // - Directory structure is tree, i.e. connected and acyclic. |
125 class DatabaseCheckHelper { | 125 class DatabaseCheckHelper { |
126 public: | 126 public: |
127 typedef fileapi::FileSystemDirectoryDatabase::FileId FileId; | 127 typedef fileapi::FileSystemDirectoryDatabase::FileId FileId; |
128 typedef fileapi::FileSystemDirectoryDatabase::FileInfo FileInfo; | 128 typedef fileapi::FileSystemDirectoryDatabase::FileInfo FileInfo; |
129 | 129 |
130 DatabaseCheckHelper(fileapi::FileSystemDirectoryDatabase* dir_db, | 130 DatabaseCheckHelper(fileapi::FileSystemDirectoryDatabase* dir_db, |
131 leveldb::DB* db, | 131 leveldb::DB* db, |
132 const FilePath& path); | 132 const base::FilePath& path); |
133 | 133 |
134 bool IsFileSystemConsistent() { | 134 bool IsFileSystemConsistent() { |
135 return IsDatabaseEmpty() || | 135 return IsDatabaseEmpty() || |
136 (ScanDatabase() && ScanDirectory() && ScanHierarchy()); | 136 (ScanDatabase() && ScanDirectory() && ScanHierarchy()); |
137 } | 137 } |
138 | 138 |
139 private: | 139 private: |
140 bool IsDatabaseEmpty(); | 140 bool IsDatabaseEmpty(); |
141 // These 3 methods need to be called in the order. Each method requires its | 141 // These 3 methods need to be called in the order. Each method requires its |
142 // previous method finished successfully. They also require the database is | 142 // previous method finished successfully. They also require the database is |
143 // not empty. | 143 // not empty. |
144 bool ScanDatabase(); | 144 bool ScanDatabase(); |
145 bool ScanDirectory(); | 145 bool ScanDirectory(); |
146 bool ScanHierarchy(); | 146 bool ScanHierarchy(); |
147 | 147 |
148 fileapi::FileSystemDirectoryDatabase* dir_db_; | 148 fileapi::FileSystemDirectoryDatabase* dir_db_; |
149 leveldb::DB* db_; | 149 leveldb::DB* db_; |
150 FilePath path_; | 150 base::FilePath path_; |
151 | 151 |
152 std::set<FilePath> files_in_db_; | 152 std::set<base::FilePath> files_in_db_; |
153 | 153 |
154 size_t num_directories_in_db_; | 154 size_t num_directories_in_db_; |
155 size_t num_files_in_db_; | 155 size_t num_files_in_db_; |
156 size_t num_hierarchy_links_in_db_; | 156 size_t num_hierarchy_links_in_db_; |
157 | 157 |
158 FileId last_file_id_; | 158 FileId last_file_id_; |
159 FileId last_integer_; | 159 FileId last_integer_; |
160 }; | 160 }; |
161 | 161 |
162 DatabaseCheckHelper::DatabaseCheckHelper( | 162 DatabaseCheckHelper::DatabaseCheckHelper( |
163 fileapi::FileSystemDirectoryDatabase* dir_db, | 163 fileapi::FileSystemDirectoryDatabase* dir_db, |
164 leveldb::DB* db, | 164 leveldb::DB* db, |
165 const FilePath& path) | 165 const base::FilePath& path) |
166 : dir_db_(dir_db), db_(db), path_(path), | 166 : dir_db_(dir_db), db_(db), path_(path), |
167 num_directories_in_db_(0), | 167 num_directories_in_db_(0), |
168 num_files_in_db_(0), | 168 num_files_in_db_(0), |
169 num_hierarchy_links_in_db_(0), | 169 num_hierarchy_links_in_db_(0), |
170 last_file_id_(-1), last_integer_(-1) { | 170 last_file_id_(-1), last_integer_(-1) { |
171 DCHECK(dir_db_); | 171 DCHECK(dir_db_); |
172 DCHECK(db_); | 172 DCHECK(db_); |
173 DCHECK(!path_.empty() && file_util::DirectoryExists(path_)); | 173 DCHECK(!path_.empty() && file_util::DirectoryExists(path_)); |
174 } | 174 } |
175 | 175 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 } | 253 } |
254 | 254 |
255 // TODO(tzik): Add constraint for |last_integer_| to avoid possible | 255 // TODO(tzik): Add constraint for |last_integer_| to avoid possible |
256 // data path confliction on ObfuscatedFileUtil. | 256 // data path confliction on ObfuscatedFileUtil. |
257 return max_file_id <= last_file_id_; | 257 return max_file_id <= last_file_id_; |
258 } | 258 } |
259 | 259 |
260 bool DatabaseCheckHelper::ScanDirectory() { | 260 bool DatabaseCheckHelper::ScanDirectory() { |
261 // TODO(kinuko): Scans all local file system entries to verify each of them | 261 // TODO(kinuko): Scans all local file system entries to verify each of them |
262 // has a database entry. | 262 // has a database entry. |
263 const FilePath kExcludes[] = { | 263 const base::FilePath kExcludes[] = { |
264 FilePath(kDirectoryDatabaseName), | 264 base::FilePath(kDirectoryDatabaseName), |
265 FilePath(fileapi::FileSystemUsageCache::kUsageFileName), | 265 base::FilePath(fileapi::FileSystemUsageCache::kUsageFileName), |
266 }; | 266 }; |
267 | 267 |
268 // Any path in |pending_directories| is relative to |path_|. | 268 // Any path in |pending_directories| is relative to |path_|. |
269 std::stack<FilePath> pending_directories; | 269 std::stack<base::FilePath> pending_directories; |
270 pending_directories.push(FilePath()); | 270 pending_directories.push(base::FilePath()); |
271 | 271 |
272 while (!pending_directories.empty()) { | 272 while (!pending_directories.empty()) { |
273 FilePath dir_path = pending_directories.top(); | 273 base::FilePath dir_path = pending_directories.top(); |
274 pending_directories.pop(); | 274 pending_directories.pop(); |
275 | 275 |
276 file_util::FileEnumerator file_enum( | 276 file_util::FileEnumerator file_enum( |
277 dir_path.empty() ? path_ : path_.Append(dir_path), | 277 dir_path.empty() ? path_ : path_.Append(dir_path), |
278 false /* not recursive */, | 278 false /* not recursive */, |
279 file_util::FileEnumerator::DIRECTORIES | | 279 file_util::FileEnumerator::DIRECTORIES | |
280 file_util::FileEnumerator::FILES); | 280 file_util::FileEnumerator::FILES); |
281 | 281 |
282 FilePath absolute_file_path; | 282 base::FilePath absolute_file_path; |
283 while (!(absolute_file_path = file_enum.Next()).empty()) { | 283 while (!(absolute_file_path = file_enum.Next()).empty()) { |
284 file_util::FileEnumerator::FindInfo find_info; | 284 file_util::FileEnumerator::FindInfo find_info; |
285 file_enum.GetFindInfo(&find_info); | 285 file_enum.GetFindInfo(&find_info); |
286 | 286 |
287 FilePath relative_file_path; | 287 base::FilePath relative_file_path; |
288 if (!path_.AppendRelativePath(absolute_file_path, &relative_file_path)) | 288 if (!path_.AppendRelativePath(absolute_file_path, &relative_file_path)) |
289 return false; | 289 return false; |
290 | 290 |
291 if (std::find(kExcludes, kExcludes + arraysize(kExcludes), | 291 if (std::find(kExcludes, kExcludes + arraysize(kExcludes), |
292 relative_file_path) != kExcludes + arraysize(kExcludes)) | 292 relative_file_path) != kExcludes + arraysize(kExcludes)) |
293 continue; | 293 continue; |
294 | 294 |
295 if (file_util::FileEnumerator::IsDirectory(find_info)) { | 295 if (file_util::FileEnumerator::IsDirectory(find_info)) { |
296 pending_directories.push(relative_file_path); | 296 pending_directories.push(relative_file_path); |
297 continue; | 297 continue; |
298 } | 298 } |
299 | 299 |
300 // Check if the file has a database entry. | 300 // Check if the file has a database entry. |
301 std::set<FilePath>::iterator itr = files_in_db_.find(relative_file_path); | 301 std::set<base::FilePath>::iterator itr = files_in_db_.find(relative_file_p
ath); |
302 if (itr == files_in_db_.end()) { | 302 if (itr == files_in_db_.end()) { |
303 if (!file_util::Delete(absolute_file_path, false)) | 303 if (!file_util::Delete(absolute_file_path, false)) |
304 return false; | 304 return false; |
305 } else { | 305 } else { |
306 files_in_db_.erase(itr); | 306 files_in_db_.erase(itr); |
307 } | 307 } |
308 } | 308 } |
309 } | 309 } |
310 | 310 |
311 return files_in_db_.empty(); | 311 return files_in_db_.empty(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 // Check if we've visited all database entries. | 366 // Check if we've visited all database entries. |
367 return num_directories_in_db_ == visited_directories && | 367 return num_directories_in_db_ == visited_directories && |
368 num_files_in_db_ == visited_files && | 368 num_files_in_db_ == visited_files && |
369 num_hierarchy_links_in_db_ == visited_links; | 369 num_hierarchy_links_in_db_ == visited_links; |
370 } | 370 } |
371 | 371 |
372 // Returns true if the given |data_path| contains no parent references ("..") | 372 // Returns true if the given |data_path| contains no parent references ("..") |
373 // and does not refer to special system files. | 373 // and does not refer to special system files. |
374 // This is called in GetFileInfo, AddFileInfo and UpdateFileInfo to | 374 // This is called in GetFileInfo, AddFileInfo and UpdateFileInfo to |
375 // ensure we're only dealing with valid data paths. | 375 // ensure we're only dealing with valid data paths. |
376 bool VerifyDataPath(const FilePath& data_path) { | 376 bool VerifyDataPath(const base::FilePath& data_path) { |
377 // |data_path| should not contain any ".." and should be a relative path | 377 // |data_path| should not contain any ".." and should be a relative path |
378 // (to the filesystem_data_directory_). | 378 // (to the filesystem_data_directory_). |
379 if (data_path.ReferencesParent() || data_path.IsAbsolute()) | 379 if (data_path.ReferencesParent() || data_path.IsAbsolute()) |
380 return false; | 380 return false; |
381 // See if it's not pointing to the special system paths. | 381 // See if it's not pointing to the special system paths. |
382 const FilePath kExcludes[] = { | 382 const base::FilePath kExcludes[] = { |
383 FilePath(kDirectoryDatabaseName), | 383 base::FilePath(kDirectoryDatabaseName), |
384 FilePath(fileapi::FileSystemUsageCache::kUsageFileName), | 384 base::FilePath(fileapi::FileSystemUsageCache::kUsageFileName), |
385 }; | 385 }; |
386 for (size_t i = 0; i < arraysize(kExcludes); ++i) { | 386 for (size_t i = 0; i < arraysize(kExcludes); ++i) { |
387 if (data_path == kExcludes[i] || kExcludes[i].IsParent(data_path)) | 387 if (data_path == kExcludes[i] || kExcludes[i].IsParent(data_path)) |
388 return false; | 388 return false; |
389 } | 389 } |
390 return true; | 390 return true; |
391 } | 391 } |
392 | 392 |
393 } // namespace | 393 } // namespace |
394 | 394 |
395 namespace fileapi { | 395 namespace fileapi { |
396 | 396 |
397 FileSystemDirectoryDatabase::FileInfo::FileInfo() : parent_id(0) { | 397 FileSystemDirectoryDatabase::FileInfo::FileInfo() : parent_id(0) { |
398 } | 398 } |
399 | 399 |
400 FileSystemDirectoryDatabase::FileInfo::~FileInfo() { | 400 FileSystemDirectoryDatabase::FileInfo::~FileInfo() { |
401 } | 401 } |
402 | 402 |
403 FileSystemDirectoryDatabase::FileSystemDirectoryDatabase( | 403 FileSystemDirectoryDatabase::FileSystemDirectoryDatabase( |
404 const FilePath& filesystem_data_directory) | 404 const base::FilePath& filesystem_data_directory) |
405 : filesystem_data_directory_(filesystem_data_directory) { | 405 : filesystem_data_directory_(filesystem_data_directory) { |
406 } | 406 } |
407 | 407 |
408 FileSystemDirectoryDatabase::~FileSystemDirectoryDatabase() { | 408 FileSystemDirectoryDatabase::~FileSystemDirectoryDatabase() { |
409 } | 409 } |
410 | 410 |
411 bool FileSystemDirectoryDatabase::GetChildWithName( | 411 bool FileSystemDirectoryDatabase::GetChildWithName( |
412 FileId parent_id, const FilePath::StringType& name, FileId* child_id) { | 412 FileId parent_id, const base::FilePath::StringType& name, FileId* child_id)
{ |
413 if (!Init(REPAIR_ON_CORRUPTION)) | 413 if (!Init(REPAIR_ON_CORRUPTION)) |
414 return false; | 414 return false; |
415 DCHECK(child_id); | 415 DCHECK(child_id); |
416 std::string child_key = GetChildLookupKey(parent_id, name); | 416 std::string child_key = GetChildLookupKey(parent_id, name); |
417 std::string child_id_string; | 417 std::string child_id_string; |
418 leveldb::Status status = | 418 leveldb::Status status = |
419 db_->Get(leveldb::ReadOptions(), child_key, &child_id_string); | 419 db_->Get(leveldb::ReadOptions(), child_key, &child_id_string); |
420 if (status.IsNotFound()) | 420 if (status.IsNotFound()) |
421 return false; | 421 return false; |
422 if (status.ok()) { | 422 if (status.ok()) { |
423 if (!base::StringToInt64(child_id_string, child_id)) { | 423 if (!base::StringToInt64(child_id_string, child_id)) { |
424 LOG(ERROR) << "Hit database corruption!"; | 424 LOG(ERROR) << "Hit database corruption!"; |
425 return false; | 425 return false; |
426 } | 426 } |
427 return true; | 427 return true; |
428 } | 428 } |
429 HandleError(FROM_HERE, status); | 429 HandleError(FROM_HERE, status); |
430 return false; | 430 return false; |
431 } | 431 } |
432 | 432 |
433 bool FileSystemDirectoryDatabase::GetFileWithPath( | 433 bool FileSystemDirectoryDatabase::GetFileWithPath( |
434 const FilePath& path, FileId* file_id) { | 434 const base::FilePath& path, FileId* file_id) { |
435 std::vector<FilePath::StringType> components; | 435 std::vector<base::FilePath::StringType> components; |
436 VirtualPath::GetComponents(path, &components); | 436 VirtualPath::GetComponents(path, &components); |
437 FileId local_id = 0; | 437 FileId local_id = 0; |
438 std::vector<FilePath::StringType>::iterator iter; | 438 std::vector<base::FilePath::StringType>::iterator iter; |
439 for (iter = components.begin(); iter != components.end(); ++iter) { | 439 for (iter = components.begin(); iter != components.end(); ++iter) { |
440 FilePath::StringType name; | 440 base::FilePath::StringType name; |
441 name = *iter; | 441 name = *iter; |
442 if (name == FILE_PATH_LITERAL("/")) | 442 if (name == FILE_PATH_LITERAL("/")) |
443 continue; | 443 continue; |
444 if (!GetChildWithName(local_id, name, &local_id)) | 444 if (!GetChildWithName(local_id, name, &local_id)) |
445 return false; | 445 return false; |
446 } | 446 } |
447 *file_id = local_id; | 447 *file_id = local_id; |
448 return true; | 448 return true; |
449 } | 449 } |
450 | 450 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 LOG(ERROR) << "Resolved data path is invalid: " | 490 LOG(ERROR) << "Resolved data path is invalid: " |
491 << info->data_path.value(); | 491 << info->data_path.value(); |
492 return false; | 492 return false; |
493 } | 493 } |
494 return true; | 494 return true; |
495 } | 495 } |
496 // Special-case the root, for databases that haven't been initialized yet. | 496 // Special-case the root, for databases that haven't been initialized yet. |
497 // Without this, a query for the root's file info, made before creating the | 497 // Without this, a query for the root's file info, made before creating the |
498 // first file in the database, will fail and confuse callers. | 498 // first file in the database, will fail and confuse callers. |
499 if (status.IsNotFound() && !file_id) { | 499 if (status.IsNotFound() && !file_id) { |
500 info->name = FilePath::StringType(); | 500 info->name = base::FilePath::StringType(); |
501 info->data_path = FilePath(); | 501 info->data_path = base::FilePath(); |
502 info->modification_time = base::Time::Now(); | 502 info->modification_time = base::Time::Now(); |
503 info->parent_id = 0; | 503 info->parent_id = 0; |
504 return true; | 504 return true; |
505 } | 505 } |
506 HandleError(FROM_HERE, status); | 506 HandleError(FROM_HERE, status); |
507 return false; | 507 return false; |
508 } | 508 } |
509 | 509 |
510 bool FileSystemDirectoryDatabase::AddFileInfo( | 510 bool FileSystemDirectoryDatabase::AddFileInfo( |
511 const FileInfo& info, FileId* file_id) { | 511 const FileInfo& info, FileId* file_id) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 return false; | 679 return false; |
680 } | 680 } |
681 // The database must not yet exist; initialize it. | 681 // The database must not yet exist; initialize it. |
682 if (!StoreDefaultValues()) | 682 if (!StoreDefaultValues()) |
683 return false; | 683 return false; |
684 | 684 |
685 return GetNextInteger(next); | 685 return GetNextInteger(next); |
686 } | 686 } |
687 | 687 |
688 // static | 688 // static |
689 bool FileSystemDirectoryDatabase::DestroyDatabase(const FilePath& path) { | 689 bool FileSystemDirectoryDatabase::DestroyDatabase(const base::FilePath& path) { |
690 std::string name = FilePathToString(path.Append(kDirectoryDatabaseName)); | 690 std::string name = FilePathToString(path.Append(kDirectoryDatabaseName)); |
691 leveldb::Status status = leveldb::DestroyDB(name, leveldb::Options()); | 691 leveldb::Status status = leveldb::DestroyDB(name, leveldb::Options()); |
692 if (status.ok()) | 692 if (status.ok()) |
693 return true; | 693 return true; |
694 LOG(WARNING) << "Failed to destroy a database with status " << | 694 LOG(WARNING) << "Failed to destroy a database with status " << |
695 status.ToString(); | 695 status.ToString(); |
696 return false; | 696 return false; |
697 } | 697 } |
698 | 698 |
699 bool FileSystemDirectoryDatabase::Init(RecoveryOption recovery_option) { | 699 bool FileSystemDirectoryDatabase::Init(RecoveryOption recovery_option) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 | 897 |
898 void FileSystemDirectoryDatabase::HandleError( | 898 void FileSystemDirectoryDatabase::HandleError( |
899 const tracked_objects::Location& from_here, | 899 const tracked_objects::Location& from_here, |
900 const leveldb::Status& status) { | 900 const leveldb::Status& status) { |
901 LOG(ERROR) << "FileSystemDirectoryDatabase failed at: " | 901 LOG(ERROR) << "FileSystemDirectoryDatabase failed at: " |
902 << from_here.ToString() << " with error: " << status.ToString(); | 902 << from_here.ToString() << " with error: " << status.ToString(); |
903 db_.reset(); | 903 db_.reset(); |
904 } | 904 } |
905 | 905 |
906 } // namespace fileapi | 906 } // namespace fileapi |
OLD | NEW |