Remove size from s3 filenames
This commit is contained in:
@@ -228,18 +228,17 @@ func IsWALPath(s string) bool {
|
||||
|
||||
// ParseWALPath returns the index & offset for the WAL file.
|
||||
// Returns an error if the path is not a valid snapshot path.
|
||||
func ParseWALPath(s string) (index int, offset, sz int64, ext string, err error) {
|
||||
func ParseWALPath(s string) (index int, offset int64, ext string, err error) {
|
||||
s = filepath.Base(s)
|
||||
|
||||
a := walPathRegex.FindStringSubmatch(s)
|
||||
if a == nil {
|
||||
return 0, 0, 0, "", fmt.Errorf("invalid wal path: %s", s)
|
||||
return 0, 0, "", fmt.Errorf("invalid wal path: %s", s)
|
||||
}
|
||||
|
||||
i64, _ := strconv.ParseUint(a[1], 16, 64)
|
||||
off64, _ := strconv.ParseUint(a[2], 16, 64)
|
||||
sz64, _ := strconv.ParseUint(a[3], 16, 64)
|
||||
return int(i64), int64(off64), int64(sz64), a[4], nil
|
||||
return int(i64), int64(off64), a[3], nil
|
||||
}
|
||||
|
||||
// FormatWALPath formats a WAL filename with a given index.
|
||||
@@ -248,15 +247,14 @@ func FormatWALPath(index int) string {
|
||||
return fmt.Sprintf("%08x%s", index, WALExt)
|
||||
}
|
||||
|
||||
// FormatWALPathWithOffsetSize formats a WAL filename with a given index, offset & size.
|
||||
func FormatWALPathWithOffsetSize(index int, offset, sz int64) string {
|
||||
// FormatWALPathWithOffset formats a WAL filename with a given index & offset.
|
||||
func FormatWALPathWithOffset(index int, offset int64) string {
|
||||
assert(index >= 0, "wal index must be non-negative")
|
||||
assert(offset >= 0, "wal offset must be non-negative")
|
||||
assert(sz >= 0, "wal size must be non-negative")
|
||||
return fmt.Sprintf("%08x_%08x_%08x%s", index, offset, sz, WALExt)
|
||||
return fmt.Sprintf("%08x_%08x%s", index, offset, WALExt)
|
||||
}
|
||||
|
||||
var walPathRegex = regexp.MustCompile(`^([0-9a-f]{8})(?:_([0-9a-f]{8})_([0-9a-f]{8}))?(.wal(?:.gz)?)$`)
|
||||
var walPathRegex = regexp.MustCompile(`^([0-9a-f]{8})(?:_([0-9a-f]{8}))?(.wal(?:.gz)?)$`)
|
||||
|
||||
// isHexChar returns true if ch is a lowercase hex character.
|
||||
func isHexChar(ch rune) bool {
|
||||
|
||||
Reference in New Issue
Block a user