@@ -29,7 +29,7 @@ import (
2929// directory of scratches created. A scratch manages the SSTs created during a
3030// specific snapshot.
3131type SSTSnapshotStorage struct {
32- engine storage. Engine
32+ env * fs. Env
3333 limiter * rate.Limiter
3434 dir string
3535 mu struct {
@@ -41,7 +41,7 @@ type SSTSnapshotStorage struct {
4141// NewSSTSnapshotStorage creates a new SST snapshot storage.
4242func NewSSTSnapshotStorage (engine storage.Engine , limiter * rate.Limiter ) SSTSnapshotStorage {
4343 return SSTSnapshotStorage {
44- engine : engine ,
44+ env : engine . Env () ,
4545 limiter : limiter ,
4646 dir : filepath .Join (engine .GetAuxiliaryDir (), "sstsnapshot" ),
4747 mu : struct {
@@ -70,7 +70,7 @@ func (s *SSTSnapshotStorage) NewScratchSpace(
7070
7171// Clear removes all created directories and SSTs.
7272func (s * SSTSnapshotStorage ) Clear () error {
73- return s .engine . Env () .RemoveAll (s .dir )
73+ return s .env .RemoveAll (s .dir )
7474}
7575
7676// scratchClosed is called when an SSTSnapshotStorageScratch created by this
@@ -91,7 +91,7 @@ func (s *SSTSnapshotStorage) scratchClosed(rangeID roachpb.RangeID) {
9191 // Suppressing an error here is okay, as orphaned directories are at worst
9292 // a performance issue when we later walk directories in pebble.Capacity()
9393 // but not a correctness issue.
94- _ = s .engine . Env () .RemoveAll (filepath .Join (s .dir , strconv .Itoa (int (rangeID ))))
94+ _ = s .env .RemoveAll (filepath .Join (s .dir , strconv .Itoa (int (rangeID ))))
9595 }
9696}
9797
@@ -113,7 +113,7 @@ func (s *SSTSnapshotStorageScratch) filename(id int) string {
113113}
114114
115115func (s * SSTSnapshotStorageScratch ) createDir () error {
116- err := s .storage .engine . Env () .MkdirAll (s .snapDir , os .ModePerm )
116+ err := s .storage .env .MkdirAll (s .snapDir , os .ModePerm )
117117 s .dirCreated = s .dirCreated || err == nil
118118 return err
119119}
@@ -187,7 +187,7 @@ func (s *SSTSnapshotStorageScratch) Close() error {
187187 }
188188 s .closed = true
189189 defer s .storage .scratchClosed (s .rangeID )
190- return s .storage .engine . Env () .RemoveAll (s .snapDir )
190+ return s .storage .env .RemoveAll (s .snapDir )
191191}
192192
193193// SSTSnapshotStorageFile is an SST file managed by a
@@ -220,9 +220,9 @@ func (f *SSTSnapshotStorageFile) ensureFile() error {
220220 }
221221 var err error
222222 if f .bytesPerSync > 0 {
223- f .file , err = fs .CreateWithSync (f .scratch .storage .engine . Env () , f .filename , int (f .bytesPerSync ), fs .RaftSnapshotWriteCategory )
223+ f .file , err = fs .CreateWithSync (f .scratch .storage .env , f .filename , int (f .bytesPerSync ), fs .RaftSnapshotWriteCategory )
224224 } else {
225- f .file , err = f .scratch .storage .engine . Env () .Create (f .filename , fs .RaftSnapshotWriteCategory )
225+ f .file , err = f .scratch .storage .env .Create (f .filename , fs .RaftSnapshotWriteCategory )
226226 }
227227 if err != nil {
228228 return err
0 commit comments