mirror of
https://github.com/distribution/distribution.git
synced 2025-09-19 01:16:59 +00:00
Remove registry storage testdriver
Signed-off-by: glefloch <glfloch@gmail.com>
This commit is contained in:
@@ -251,6 +251,8 @@ func (d *driver) Walk(ctx context.Context, path string, f storagedriver.WalkFn)
|
||||
type writer struct {
|
||||
d *driver
|
||||
f *file
|
||||
buffer []byte
|
||||
buffSize int
|
||||
closed bool
|
||||
committed bool
|
||||
cancelled bool
|
||||
@@ -274,8 +276,17 @@ func (w *writer) Write(p []byte) (int, error) {
|
||||
|
||||
w.d.mutex.Lock()
|
||||
defer w.d.mutex.Unlock()
|
||||
if cap(w.buffer) < len(p)+w.buffSize {
|
||||
data := make([]byte, len(w.buffer), len(p)+w.buffSize)
|
||||
copy(data, w.buffer)
|
||||
w.buffer = data
|
||||
}
|
||||
|
||||
return w.f.WriteAt(p, int64(len(w.f.data)))
|
||||
w.buffer = w.buffer[:w.buffSize+len(p)]
|
||||
n := copy(w.buffer[w.buffSize:w.buffSize+len(p)], p)
|
||||
w.buffSize += n
|
||||
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func (w *writer) Size() int64 {
|
||||
@@ -290,6 +301,8 @@ func (w *writer) Close() error {
|
||||
return fmt.Errorf("already closed")
|
||||
}
|
||||
w.closed = true
|
||||
w.flush()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -316,5 +329,16 @@ func (w *writer) Commit() error {
|
||||
return fmt.Errorf("already cancelled")
|
||||
}
|
||||
w.committed = true
|
||||
w.flush()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *writer) flush() {
|
||||
w.d.mutex.Lock()
|
||||
defer w.d.mutex.Unlock()
|
||||
|
||||
w.f.WriteAt(w.buffer, int64(len(w.f.data)))
|
||||
w.buffer = []byte{}
|
||||
w.buffSize = 0
|
||||
}
|
||||
|
Reference in New Issue
Block a user