Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1067)

Side by Side Diff: webkit/fileapi/file_system_directory_database.cc

Issue 13946004: FileAPI: Run database recovery on IOError. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: +comment, +test for other db files Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 options.create_if_missing = true; 707 options.create_if_missing = true;
708 leveldb::DB* db; 708 leveldb::DB* db;
709 leveldb::Status status = leveldb::DB::Open(options, path, &db); 709 leveldb::Status status = leveldb::DB::Open(options, path, &db);
710 ReportInitStatus(status); 710 ReportInitStatus(status);
711 if (status.ok()) { 711 if (status.ok()) {
712 db_.reset(db); 712 db_.reset(db);
713 return true; 713 return true;
714 } 714 }
715 HandleError(FROM_HERE, status); 715 HandleError(FROM_HERE, status);
716 716
717 if (!status.IsCorruption()) 717 // Corruption due to missing necessary MANIFEST-* file causes IOError instead
718 // of Corruption error.
719 // Try to repair database even when IOError case.
720 if (!status.IsCorruption() && !status.IsIOError())
718 return false; 721 return false;
719 722
720 switch (recovery_option) { 723 switch (recovery_option) {
721 case FAIL_ON_CORRUPTION: 724 case FAIL_ON_CORRUPTION:
722 return false; 725 return false;
723 case REPAIR_ON_CORRUPTION: 726 case REPAIR_ON_CORRUPTION:
724 LOG(WARNING) << "Corrupted FileSystemDirectoryDatabase detected." 727 LOG(WARNING) << "Corrupted FileSystemDirectoryDatabase detected."
725 << " Attempting to repair."; 728 << " Attempting to repair.";
726 if (RepairDatabase(path)) 729 if (RepairDatabase(path))
727 return true; 730 return true;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 900
898 void FileSystemDirectoryDatabase::HandleError( 901 void FileSystemDirectoryDatabase::HandleError(
899 const tracked_objects::Location& from_here, 902 const tracked_objects::Location& from_here,
900 const leveldb::Status& status) { 903 const leveldb::Status& status) {
901 LOG(ERROR) << "FileSystemDirectoryDatabase failed at: " 904 LOG(ERROR) << "FileSystemDirectoryDatabase failed at: "
902 << from_here.ToString() << " with error: " << status.ToString(); 905 << from_here.ToString() << " with error: " << status.ToString();
903 db_.reset(); 906 db_.reset();
904 } 907 }
905 908
906 } // namespace fileapi 909 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_database_test_helper.cc ('k') | webkit/fileapi/file_system_directory_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698