Skip to content

withBinaryFileDurableAtomic fails with nested folders #160

@lehins

Description

@lehins

Whenever a file that is being written to is located in a sub directory withBinaryFileDurableAtomic results in a runtime exception during the atomic rename.

Same problem applies to writeBinaryFileDurableAtomic.

Here is a short repro:

import Import
import RIO.Directory
import RIO.File

run :: RIO App ()
run = do
  logInfo "We're inside the application!"

  let foo = "foo.txt"
  withBinaryFileDurableAtomic foo WriteMode $ \h -> do
    hPutBuilder h "foo"
  logInfo $ "Written " <> fromString foo

  let barFoo = "bar/foo.txt"
  createDirectoryIfMissing True barFoo
  withBinaryFileDurableAtomic barFoo WriteMode $ \h -> do
    hPutBuilder h "bar - foo"
  logInfo $ "Written " <> fromString barFoo

Which results in:

$ stack run
We're inside the application!
Written foo.txt
atomic-durable-exe: closeFileDurableAtomic - renameFile: does not exist (No such file or directory)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions