This repository has been archived by the owner on Mar 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from benbjohnson/fsck
Add DB.Check().
- Loading branch information
Showing
7 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/boltdb/bolt" | ||
) | ||
|
||
// Check performs a consistency check on the database and prints any errors found. | ||
func Check(path string) { | ||
if _, err := os.Stat(path); os.IsNotExist(err) { | ||
fatal(err) | ||
return | ||
} | ||
|
||
db, err := bolt.Open(path, 0600) | ||
if err != nil { | ||
fatal(err) | ||
return | ||
} | ||
defer db.Close() | ||
|
||
// Perform consistency check. | ||
if err := db.Check(); err != nil { | ||
if errors, ok := err.(bolt.ErrorList); ok { | ||
for _, err := range errors { | ||
println(err) | ||
} | ||
} | ||
fatalln(err) | ||
return | ||
} | ||
println("OK") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters