fixing empty albums

This commit is contained in:
nek0 2016-11-19 22:16:36 +01:00
parent 1122e9a756
commit a3a1942438

View file

@ -191,7 +191,7 @@ writeOnDrive :: FileInfo -> UserId -> AlbumId -> Handler FP.FilePath
writeOnDrive fil userId albumId = do writeOnDrive fil userId albumId = do
--filen <- return $ fileName fil --filen <- return $ fileName fil
album <- runDB $ getJust albumId album <- runDB $ getJust albumId
let [PersistInt64 int] = keyToValues $ maximum $ albumContent album let [PersistInt64 int] = if albumContent album == [] then [PersistInt64 1] else keyToValues $ maximum $ albumContent album
let filen = show $ fromIntegral int + 1 let filen = show $ fromIntegral int + 1
let ext = FP.takeExtension $ T.unpack $ fileName fil 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 let path = "static" FP.</> "data" FP.</> T.unpack (extractKey userId) FP.</> T.unpack (extractKey albumId) FP.</> filen ++ ext