Skip to content

Commit 59cd64b

Browse files
committed
[#198] Capture non-ASCII file names in the right way
Problem: Data.ByteString.Char8.pack breaks unicode sequencies Solution: replace pack with transformation to Text and encoding to utf-8
1 parent fa686f8 commit 59cd64b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

hnix-store-core/src/System/Nix/Internal/Nar/Streamer.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import qualified Data.ByteString as Bytes
1616
import qualified Data.ByteString.Char8 as Bytes.Char8
1717
import qualified Data.ByteString.Lazy as Bytes.Lazy
1818
import qualified Data.Serialize as Serial
19+
import qualified Data.Text as T (pack)
20+
import qualified Data.Text.Encoding as TE (encodeUtf8)
1921
import qualified System.Directory as Directory
2022
import System.FilePath ((</>))
2123

@@ -65,7 +67,7 @@ streamNarIO effs basePath yield = do
6567
if isSymLink then do
6668
target <- IO.liftIO $ Nar.narReadLink effs path
6769
yield $
68-
strs ["type", "symlink", "target", Bytes.Char8.pack target]
70+
strs ["type", "symlink", "target", filePathToBS target]
6971
else do
7072
isDir <- IO.liftIO $ Nar.narIsDir effs path
7173
if isDir then do
@@ -75,7 +77,7 @@ streamNarIO effs basePath yield = do
7577
yield $ str "entry"
7678
parens $ do
7779
let fullName = path </> f
78-
yield $ strs ["name", Bytes.Char8.pack f, "node"]
80+
yield $ strs ["name", filePathToBS f, "node"]
7981
parens $ go fullName
8082
else do
8183
isExec <- IO.liftIO $ isExecutable effs path
@@ -86,6 +88,8 @@ streamNarIO effs basePath yield = do
8688
yield $ int fSize
8789
yieldFile path fSize
8890

91+
filePathToBS = TE.encodeUtf8 . T.pack
92+
8993
parens act = do
9094
yield $ str "("
9195
r <- act

0 commit comments

Comments
 (0)