S3 replica
This commit is contained in:
13
db.go
13
db.go
@@ -117,6 +117,11 @@ func NewDB(path string) *DB {
|
||||
return db
|
||||
}
|
||||
|
||||
// SQLDB returns a reference to the underlying sql.DB connection.
|
||||
func (db *DB) SQLDB() *sql.DB {
|
||||
return db.db
|
||||
}
|
||||
|
||||
// Path returns the path to the database.
|
||||
func (db *DB) Path() string {
|
||||
return db.path
|
||||
@@ -181,7 +186,7 @@ func (db *DB) CurrentShadowWALIndex(generation string) (index int, size int64, e
|
||||
if !strings.HasSuffix(fi.Name(), WALExt) {
|
||||
continue
|
||||
}
|
||||
if v, _, _, err := ParseWALPath(fi.Name()); err != nil {
|
||||
if v, _, _, _, err := ParseWALPath(fi.Name()); err != nil {
|
||||
continue // invalid wal filename
|
||||
} else if v > index {
|
||||
index = v
|
||||
@@ -478,7 +483,7 @@ func (db *DB) cleanWAL() error {
|
||||
return err
|
||||
}
|
||||
for _, fi := range fis {
|
||||
if idx, _, _, err := ParseWALPath(fi.Name()); err != nil || idx >= min {
|
||||
if idx, _, _, _, err := ParseWALPath(fi.Name()); err != nil || idx >= min {
|
||||
continue
|
||||
}
|
||||
if err := os.Remove(filepath.Join(dir, fi.Name())); err != nil {
|
||||
@@ -858,7 +863,7 @@ func (db *DB) syncWAL(info syncInfo) (newSize int64, err error) {
|
||||
|
||||
// Parse index of current shadow WAL file.
|
||||
dir, base := filepath.Split(info.shadowWALPath)
|
||||
index, _, _, err := ParseWALPath(base)
|
||||
index, _, _, _, err := ParseWALPath(base)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("cannot parse shadow wal filename: %s", base)
|
||||
}
|
||||
@@ -1217,7 +1222,7 @@ func (db *DB) checkpointAndInit(info syncInfo, mode string) error {
|
||||
}
|
||||
|
||||
// Parse index of current shadow WAL file.
|
||||
index, _, _, err := ParseWALPath(info.shadowWALPath)
|
||||
index, _, _, _, err := ParseWALPath(info.shadowWALPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot parse shadow wal filename: %s", info.shadowWALPath)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user