GFServer.hs: apply UTF8 encoding when saving uploaded files

This fixes a bug introduced on May 16.
This commit is contained in:
hallgren
2012-05-28 11:21:30 +00:00
parent 6dfd337568
commit a3a491d8fc
2 changed files with 3 additions and 7 deletions

View File

@@ -180,8 +180,7 @@ handle state0 cache execute1
return (state,json200 (jsonresult cwd ('/':dir++"/") cmd out files))
upload files =
do let update (name,contents)= updateFile name contents
mapM_ update files
do mapM_ (uncurry updateFile) files
return (state,resp204)
jsonList =
@@ -354,8 +353,9 @@ contentTypeFromExt ext =
bin t = (t,readBinaryFile)
-- * IO utilities
updateFile path new =
updateFile path new0 =
do old <- try $ readBinaryFile path
let new = encodeString new0
when (Right new/=old) $ do logPutStrLn $ "Updating "++path
seq (either (const 0) length old) $
writeBinaryFile path new