From c2aad1c7ff4f210a1c773691c21e9fdad6b468e1 Mon Sep 17 00:00:00 2001 From: chrislu Date: Wed, 22 Dec 2021 17:20:44 -0800 Subject: [PATCH] detect non streaming mode on first write request --- weed/filesys/page_writer_pattern.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/weed/filesys/page_writer_pattern.go b/weed/filesys/page_writer_pattern.go index 42ca3d969..44b69cda7 100644 --- a/weed/filesys/page_writer_pattern.go +++ b/weed/filesys/page_writer_pattern.go @@ -14,18 +14,21 @@ type WriterPattern struct { func NewWriterPattern(fileName string, chunkSize int64) *WriterPattern { return &WriterPattern{ isStreaming: true, - lastWriteOffset: 0, + lastWriteOffset: -1, chunkSize: chunkSize, fileName: fileName, } } func (rp *WriterPattern) MonitorWriteAt(offset int64, size int) { - if rp.lastWriteOffset == 0 { - } if rp.lastWriteOffset > offset { rp.isStreaming = false } + if rp.lastWriteOffset == -1 { + if offset != 0 { + rp.isStreaming = false + } + } rp.lastWriteOffset = offset }