-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pages checksum verification #736
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0f52403
Add page checksums verify functions
usernamedt cf7e678
Add file corrupt blocks field to backup sentinel
usernamedt 1f2fb8c
Add MultiCloser to ioextensions
usernamedt dee53dc
Add page verification to tar ball file packer
usernamedt 9fde2d7
Add toggle for page checksum verification
usernamedt 1dc6796
Fix bundle test
usernamedt 4efeef1
Store all errors in MultiCloser's Close()
usernamedt 50e27bd
Store corrupted blocks count && add flag for storing all corrupted bl…
usernamedt File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,36 @@ | ||
package internal | ||
|
||
import "time" | ||
import ( | ||
"sort" | ||
"time" | ||
) | ||
|
||
const MaxCorruptBlocksInFileDesc int = 10 | ||
|
||
type BackupFileDescription struct { | ||
IsIncremented bool // should never be both incremented and Skipped | ||
IsSkipped bool | ||
MTime time.Time | ||
CorruptBlocks []uint32 `json:",omitempty"` | ||
} | ||
|
||
func NewBackupFileDescription(isIncremented, isSkipped bool, modTime time.Time) *BackupFileDescription { | ||
return &BackupFileDescription{isIncremented, isSkipped, modTime} | ||
return &BackupFileDescription{isIncremented, isSkipped, modTime, nil} | ||
} | ||
|
||
func (desc *BackupFileDescription) SetCorruptBlocks(corruptBlockNumbers []uint32) { | ||
sort.Slice(corruptBlockNumbers, func(i, j int) bool { | ||
return corruptBlockNumbers[i] < corruptBlockNumbers[j] | ||
}) | ||
|
||
// write no more than MaxCorruptBlocksInFileDesc | ||
desc.CorruptBlocks = make([]uint32, 0) | ||
for idx, blockNo := range corruptBlockNumbers { | ||
if idx >= MaxCorruptBlocksInFileDesc { | ||
break | ||
} | ||
desc.CorruptBlocks = append(desc.CorruptBlocks, blockNo) | ||
} | ||
} | ||
|
||
type BackupFileList map[string]BackupFileDescription |
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
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 |
---|---|---|
|
@@ -64,3 +64,24 @@ func CreateFileWith(filePath string, content io.Reader) error { | |
_, err = utility.FastCopy(file, content) | ||
return err | ||
} | ||
|
||
type MultiCloser struct { | ||
closers []io.Closer | ||
} | ||
|
||
func NewMultiCloser(closers []io.Closer) *MultiCloser { | ||
return &MultiCloser{ | ||
closers: closers, | ||
} | ||
} | ||
func (m *MultiCloser) Close() error { | ||
var err error | ||
for _, c := range m.closers { | ||
// still call Close on each, even if one returns an error | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, it will be better to save all error messages. You can combine it to a new error There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 4efeef1 |
||
if e := c.Close(); e != nil { | ||
err = e | ||
} | ||
} | ||
return err | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the actual number of corrupted blocks. Sometimes it helps to distinguish different bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And maybe a flag to keep all blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 50e27bd