|
|
@ -33,10 +33,11 @@ type freezerOpenFunc = func() (*Freezer, error) |
|
|
|
// resettableFreezer is a wrapper of the freezer which makes the
|
|
|
|
// resettableFreezer is a wrapper of the freezer which makes the
|
|
|
|
// freezer resettable.
|
|
|
|
// freezer resettable.
|
|
|
|
type resettableFreezer struct { |
|
|
|
type resettableFreezer struct { |
|
|
|
freezer *Freezer |
|
|
|
readOnly bool |
|
|
|
opener freezerOpenFunc |
|
|
|
freezer *Freezer |
|
|
|
datadir string |
|
|
|
opener freezerOpenFunc |
|
|
|
lock sync.RWMutex |
|
|
|
datadir string |
|
|
|
|
|
|
|
lock sync.RWMutex |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// newResettableFreezer creates a resettable freezer, note freezer is
|
|
|
|
// newResettableFreezer creates a resettable freezer, note freezer is
|
|
|
@ -60,9 +61,10 @@ func newResettableFreezer(datadir string, namespace string, readonly bool, maxTa |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
return &resettableFreezer{ |
|
|
|
return &resettableFreezer{ |
|
|
|
freezer: freezer, |
|
|
|
readOnly: readonly, |
|
|
|
opener: opener, |
|
|
|
freezer: freezer, |
|
|
|
datadir: datadir, |
|
|
|
opener: opener, |
|
|
|
|
|
|
|
datadir: datadir, |
|
|
|
}, nil |
|
|
|
}, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -74,6 +76,9 @@ func (f *resettableFreezer) Reset() error { |
|
|
|
f.lock.Lock() |
|
|
|
f.lock.Lock() |
|
|
|
defer f.lock.Unlock() |
|
|
|
defer f.lock.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if f.readOnly { |
|
|
|
|
|
|
|
return errReadOnly |
|
|
|
|
|
|
|
} |
|
|
|
if err := f.freezer.Close(); err != nil { |
|
|
|
if err := f.freezer.Close(); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|