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_origin_database.h" | 5 #include "webkit/fileapi/file_system_origin_database.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 options.create_if_missing = true; | 77 options.create_if_missing = true; |
78 leveldb::DB* db; | 78 leveldb::DB* db; |
79 leveldb::Status status = leveldb::DB::Open(options, path, &db); | 79 leveldb::Status status = leveldb::DB::Open(options, path, &db); |
80 ReportInitStatus(status); | 80 ReportInitStatus(status); |
81 if (status.ok()) { | 81 if (status.ok()) { |
82 db_.reset(db); | 82 db_.reset(db); |
83 return true; | 83 return true; |
84 } | 84 } |
85 HandleError(FROM_HERE, status); | 85 HandleError(FROM_HERE, status); |
86 | 86 |
87 if (!status.IsCorruption()) | 87 // Corruption due to missing necessary MANIFEST-* file causes IOError instead |
| 88 // of Corruption error. |
| 89 // Try to repair database even when IOError case. |
| 90 if (!status.IsCorruption() && !status.IsIOError()) |
88 return false; | 91 return false; |
89 | 92 |
90 switch (recovery_option) { | 93 switch (recovery_option) { |
91 case FAIL_ON_CORRUPTION: | 94 case FAIL_ON_CORRUPTION: |
92 return false; | 95 return false; |
93 case REPAIR_ON_CORRUPTION: | 96 case REPAIR_ON_CORRUPTION: |
94 LOG(WARNING) << "Attempting to repair FileSystemOriginDatabase."; | 97 LOG(WARNING) << "Attempting to repair FileSystemOriginDatabase."; |
95 if (RepairDatabase(path)) { | 98 if (RepairDatabase(path)) { |
96 LOG(WARNING) << "Repairing FileSystemOriginDatabase completed."; | 99 LOG(WARNING) << "Repairing FileSystemOriginDatabase completed."; |
97 return true; | 100 return true; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); | 312 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); |
310 if (!status.ok()) { | 313 if (!status.ok()) { |
311 HandleError(FROM_HERE, status); | 314 HandleError(FROM_HERE, status); |
312 return false; | 315 return false; |
313 } | 316 } |
314 *number = -1; | 317 *number = -1; |
315 return true; | 318 return true; |
316 } | 319 } |
317 | 320 |
318 } // namespace fileapi | 321 } // namespace fileapi |
OLD | NEW |