From f9af9545c1cb5e6767c34626b1eab2d175b1fa12 Mon Sep 17 00:00:00 2001 From: arkbriar Date: Mon, 9 Sep 2024 13:43:33 +0800 Subject: [PATCH] fix: fix a bug in iterator that no file found Signed-off-by: arkbriar --- internal/filechannel/filechannel.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/filechannel/filechannel.go b/internal/filechannel/filechannel.go index ce1877e..ed4ea4f 100644 --- a/internal/filechannel/filechannel.go +++ b/internal/filechannel/filechannel.go @@ -244,9 +244,14 @@ func (it *Iterator) openPlainFile() error { } func (it *Iterator) openFile() error { - err := it.openCompressedFile() + // Open plain file first. If it's not found, then the compressed file must have been + // created. If the compressed file is not found, it's an error. Guaranteed by the + // compression algorithm: + // rename(compressing, compressed) + // delete(plain) + err := it.openPlainFile() if os.IsNotExist(err) { - return it.openPlainFile() + return it.openCompressedFile() } return err }