mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-17 20:51:55 +01:00
checkpoint, bug fixes
This commit is contained in:
parent
889fcac38d
commit
4f9429ed8a
@ -218,7 +218,7 @@ func (s *BlockStore) WriteAt(ctx context.Context, blockId string, name string, o
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
entry.writeAt(offset, data, true)
|
entry.writeAt(offset, data, false)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -229,9 +229,10 @@ func (s *BlockStore) AppendData(ctx context.Context, blockId string, name string
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
lastPartIdx := entry.File.getLastIncompletePartNum()
|
partMap := entry.File.computePartMap(entry.File.Size, int64(len(data)))
|
||||||
if lastPartIdx != NoPartIdx {
|
incompleteParts := incompletePartsFromMap(partMap)
|
||||||
err = entry.loadDataPartsIntoCache(ctx, []int{lastPartIdx})
|
if len(incompleteParts) > 0 {
|
||||||
|
err = entry.loadDataPartsIntoCache(ctx, incompleteParts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -290,13 +291,6 @@ func (s *BlockStore) FlushCache(ctx context.Context) error {
|
|||||||
|
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
|
|
||||||
func (f *BlockFile) getLastIncompletePartNum() int {
|
|
||||||
if f.Size%partDataSize == 0 {
|
|
||||||
return NoPartIdx
|
|
||||||
}
|
|
||||||
return f.partIdxAtOffset(f.Size)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *BlockFile) partIdxAtOffset(offset int64) int {
|
func (f *BlockFile) partIdxAtOffset(offset int64) int {
|
||||||
partIdx := int(offset / partDataSize)
|
partIdx := int(offset / partDataSize)
|
||||||
if f.Opts.Circular {
|
if f.Opts.Circular {
|
||||||
|
@ -162,7 +162,7 @@ func (entry *CacheEntry) writeAt(offset int64, data []byte, replace bool) {
|
|||||||
}
|
}
|
||||||
if entry.File.Opts.Circular {
|
if entry.File.Opts.Circular {
|
||||||
startCirFileOffset := entry.File.Size - entry.File.Opts.MaxSize
|
startCirFileOffset := entry.File.Size - entry.File.Opts.MaxSize
|
||||||
if offset+int64(len(data)) < startCirFileOffset {
|
if offset+int64(len(data)) <= startCirFileOffset {
|
||||||
// write is before the start of the circular file
|
// write is before the start of the circular file
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -401,7 +401,6 @@ func TestCircularWrites(t *testing.T) {
|
|||||||
t.Fatalf("error writing data: %v", err)
|
t.Fatalf("error writing data: %v", err)
|
||||||
}
|
}
|
||||||
checkFileData(t, ctx, blockId, "c1", "123456789 123456789 123456789 123456789 123456789 ")
|
checkFileData(t, ctx, blockId, "c1", "123456789 123456789 123456789 123456789 123456789 ")
|
||||||
|
|
||||||
err = GBS.AppendData(ctx, blockId, "c1", []byte("apple"))
|
err = GBS.AppendData(ctx, blockId, "c1", []byte("apple"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error appending data: %v", err)
|
t.Fatalf("error appending data: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user