mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +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 {
|
||||
return err
|
||||
}
|
||||
entry.writeAt(offset, data, true)
|
||||
entry.writeAt(offset, data, false)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@ -229,9 +229,10 @@ func (s *BlockStore) AppendData(ctx context.Context, blockId string, name string
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
lastPartIdx := entry.File.getLastIncompletePartNum()
|
||||
if lastPartIdx != NoPartIdx {
|
||||
err = entry.loadDataPartsIntoCache(ctx, []int{lastPartIdx})
|
||||
partMap := entry.File.computePartMap(entry.File.Size, int64(len(data)))
|
||||
incompleteParts := incompletePartsFromMap(partMap)
|
||||
if len(incompleteParts) > 0 {
|
||||
err = entry.loadDataPartsIntoCache(ctx, incompleteParts)
|
||||
if err != nil {
|
||||
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 {
|
||||
partIdx := int(offset / partDataSize)
|
||||
if f.Opts.Circular {
|
||||
|
@ -162,7 +162,7 @@ func (entry *CacheEntry) writeAt(offset int64, data []byte, replace bool) {
|
||||
}
|
||||
if entry.File.Opts.Circular {
|
||||
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
|
||||
return
|
||||
}
|
||||
|
@ -401,7 +401,6 @@ func TestCircularWrites(t *testing.T) {
|
||||
t.Fatalf("error writing data: %v", err)
|
||||
}
|
||||
checkFileData(t, ctx, blockId, "c1", "123456789 123456789 123456789 123456789 123456789 ")
|
||||
|
||||
err = GBS.AppendData(ctx, blockId, "c1", []byte("apple"))
|
||||
if err != nil {
|
||||
t.Fatalf("error appending data: %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user