From a3a1942438b0b0b27ce93194622f4fbd653be2e4 Mon Sep 17 00:00:00 2001 From: nek0 Date: Sat, 19 Nov 2016 22:16:36 +0100 Subject: [PATCH] fixing empty albums --- Handler/Upload.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Handler/Upload.hs b/Handler/Upload.hs index 858a70c..6dbb81e 100755 --- a/Handler/Upload.hs +++ b/Handler/Upload.hs @@ -191,7 +191,7 @@ writeOnDrive :: FileInfo -> UserId -> AlbumId -> Handler FP.FilePath writeOnDrive fil userId albumId = do --filen <- return $ fileName fil 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 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