fix bug in file naming.

fixes bug that occurs when uploading files to an album, where media
have been previously deleted.
This commit is contained in:
nek0 2016-11-19 10:44:47 +01:00
parent 27bfdfbd7c
commit 96d2483b06

View file

@ -184,7 +184,7 @@ writeOnDrive :: FileInfo -> UserId -> AlbumId -> Handler FP.FilePath
writeOnDrive fil userId albumId = do
--filen <- return $ fileName fil
album <- runDB $ getJust albumId
let filen = show $ length (albumContent album) + 1
let filen = show $ (read $ show $ maximum $ albumContent album :: Int) + 1
let ext = FP.takeExtension $ T.unpack $ fileName fil
let path = "static" FP.</> "data" FP.</> T.unpack (extractKey userId) FP.</> T.unpack (extractKey albumId) FP.</> filen ++ ext
dde <- liftIO $ doesDirectoryExist $ FP.dropFileName path