Skip to content

Commit

Permalink
workaround for issue snapframework/snap-core#159
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Patterson authored and dbp committed Jul 21, 2015
1 parent 9cdc81d commit 61f33fd
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions digestive-functors-snap/src/Text/Digestive/Snap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@ snapFiles config = do
fmap catMaybes . mapM (storeFile tmpDir)
where
storeFile _ (_, Left _) = return Nothing
storeFile tmp (partinfo, Right path) = do
let newPath = tmp </> "_" ++ takeFileName path ++
maybe "" B.unpack (Snap.partFileName partinfo)
liftIO $ copyFile path newPath
return $ Just (T.decodeUtf8 $ Snap.partFieldName partinfo, newPath)
storeFile tmp (partinfo, Right path) =
case Snap.partFileName partinfo of
Nothing -> return Nothing
-- NOTE(dbp 2014-07-29): Workaround for issue snapframework/snap-core#159
Just name -> if name == B.pack "" then return Nothing else do
let newPath = tmp </> "_" ++ takeFileName path ++ B.unpack name
liftIO $ copyFile path newPath
return $ Just (T.decodeUtf8 $ Snap.partFieldName partinfo, newPath)

-- | Runs a form with the HTTP input provided by Snap.
--
Expand Down

0 comments on commit 61f33fd

Please sign in to comment.