Skip to content

Commit

Permalink
Move reader offset based on handle position
Browse files Browse the repository at this point in the history
  • Loading branch information
lazamar committed Jan 8, 2025
1 parent 0250711 commit 375bd63
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Ambar/Emulator/Connector/File.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import GHC.Generics (Generic)
import GHC.IO.FD (FD)
import GHC.IO.Handle (HandlePosn(..), hGetPosn)
import System.Directory (getFileSize)
import System.IO
( Handle
Expand Down Expand Up @@ -180,9 +181,8 @@ connect conn@(FileConnector {..}) logger initState producer f = do
, Text.unpack $ Text.decodeUtf8 bs
]
Right v -> return v
let entrySize = fromIntegral $ BS.length bs + BS.length "\n"
atomically $ modifyTVar c_state $ \state ->
state { c_offset = c_offset state + entrySize }
HandlePosn _ offset <- hGetPosn readHandle
atomically $ modifyTVar c_state $ \state -> state { c_offset = offset }
return value

withReadLock :: (Handle -> IO a) -> IO a
Expand Down

0 comments on commit 375bd63

Please sign in to comment.