Skip to content

Commit 50f2ae8

Browse files
authored
Merge pull request #590 from IntersectMBO/jdral/bump-fs-sim
Update fs-sim dependency
2 parents a9f1460 + 7558cf6 commit 50f2ae8

File tree

5 files changed

+15
-28
lines changed

5 files changed

+15
-28
lines changed

blockio-api/src/System/FS/BlockIO/API.hs

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ import System.FS.API (BufferOffset, FsError (..), FsPath, Handle (..),
5959
HasFS, SomeHasFS (..))
6060
import System.FS.IO (HandleIO)
6161
import qualified System.IO as GHC
62-
import System.IO.Error (doesNotExistErrorType, ioeSetErrorString,
63-
mkIOError)
62+
import System.IO.Error (ioeSetErrorString, mkIOError)
6463
import System.Posix.Types (ByteCount, FileOffset)
6564
import Text.Printf
6665

@@ -262,31 +261,10 @@ hDropCacheAll hbio h = hAdviseAll hbio h AdviceDontNeed
262261
-------------------------------------------------------------------------------}
263262

264263
{-# SPECIALISE synchroniseFile :: HasFS IO h -> HasBlockIO IO h -> FsPath -> IO () #-}
265-
-- TODO: currently, we perform an explicit check to see if the file exists and
266-
-- throw an error when it does not exist. We would prefer to be able to rely on
267-
-- withFile to throw an error for us that we could rethrow with an upated
268-
-- description/location. Unfortunately, we have to open te file in ReadWriteMode
269-
-- on Windows, and withFile currently does not support such errors. The only
270-
-- options are:
271-
--
272-
-- * AllowExisting: silently create a file if it does not exist
273-
-- * MustBeNew: throw an error if the file exists
274-
--
275-
-- We would need to add a third option to fs-api:
276-
--
277-
-- * MustExist: throw an error if the file *does not* exist
264+
-- | Synchronise a file and its contents with the storage device.
278265
synchroniseFile :: MonadThrow m => HasFS m h -> HasBlockIO m h -> FsPath -> m ()
279-
synchroniseFile hfs hbio path = do
280-
b <- FS.doesFileExist hfs path
281-
if b then
282-
FS.withFile hfs path (FS.ReadWriteMode FS.AllowExisting) $ hSynchronise hbio
283-
else
284-
throwIO $ FS.ioToFsError (FS.mkFsErrorPath hfs (FS.mkFsPath [])) ioerr
285-
where
286-
ioerr =
287-
ioeSetErrorString
288-
(mkIOError doesNotExistErrorType "synchroniseFile" Nothing Nothing)
289-
("synchroniseFile: file does not exist")
266+
synchroniseFile hfs hbio path =
267+
FS.withFile hfs path (FS.ReadWriteMode FS.MustExist) $ hSynchronise hbio
290268

291269
{-# SPECIALISE synchroniseDirectoryRecursive ::
292270
HasFS IO h

cabal.project.release

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ if (impl(ghc < 9.0) && os(windows))
3434
package text
3535
flags: -simdutf
3636

37-
-- ghc-9.12.1
37+
-- bugfix hGetBufExactly and hGetBufExactlyAt
3838
source-repository-package
3939
type: git
4040
location: https://github.com/input-output-hk/fs-sim
41-
tag: 12dae42a78b95bf290c90b6ce7d30a8a7aa0fb45
41+
tag: 55efd82e10c2b2d339bdfdc29d8d4bd8484150ba
4242
subdir:
4343
fs-api
4444
fs-sim

test/Test/Database/LSMTree/Internal/BlobFile/FS.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ prop_fault_openRelease doCreateFile om
5959
propNoDirEntries root fs .||. propNumDirEntries root 1 fs
6060
MustBeNew ->
6161
propNumDirEntries root 1 fs
62+
MustExist ->
63+
-- TODO: fix, see the TODO on openBlobFile
64+
propNoDirEntries root fs .||. propNumDirEntries root 1 fs
6265
else
6366
propNoDirEntries root fs
6467

test/Test/Database/LSMTree/Internal/WriteBufferBlobs/FS.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,8 @@ prop_fault_WriteBufferBlobs doCreateFile ae
8080
propNoDirEntries root fs .||. propNumDirEntries root 1 fs
8181
MustBeNew ->
8282
propNumDirEntries root 1 fs
83+
MustExist ->
84+
-- TODO: fix, see the TODO on openBlobFile
85+
propNoDirEntries root fs .||. propNumDirEntries root 1 fs
8386
else
8487
propNoDirEntries root fs

test/Test/Util/FS.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,12 +611,15 @@ genAllowExisting :: Gen AllowExisting
611611
genAllowExisting = elements [
612612
AllowExisting
613613
, MustBeNew
614+
, MustExist
614615
]
615616
where
616617
_coveredAllCases x = case x of
617618
AllowExisting -> ()
618619
MustBeNew -> ()
620+
MustExist -> ()
619621

620622
shrinkAllowExisting :: AllowExisting -> [AllowExisting]
621623
shrinkAllowExisting AllowExisting = []
622624
shrinkAllowExisting MustBeNew = [AllowExisting]
625+
shrinkAllowExisting MustExist = [AllowExisting, MustBeNew]

0 commit comments

Comments
 (0)