@@ -253,10 +253,10 @@ checkPieces fileLookup indices pieces req ss
253253
254254 fl <- fileLookup pieces
255255 case (fl, isFile) of
256− (FLDoesNotExist, _) -> return NotFound
257− (FLFile file, True) -> handleCache file
258− (FLFile{}, False) -> return $ Redirect $ init pieces
259− (FLFolder folder@(Folder _ contents), _) -> do
256+ (Nothing, _) -> return NotFound
257+ (Just (Right file), True) -> handleCache file
258+ (Just Right{}, False) -> return $ Redirect $ init pieces
259+ (Just (Left folder@(Folder _ contents)), _) -> do
260260 case checkIndices $ map fileName $ rights contents of
261261 Just index -> return $ Redirect $ setLast pieces $ Piece (T.unpack index) index
262262 Nothing ->
@@ -324,7 +324,7 @@ defaultDirListing = StaticDirListing (Just defaultListing) []
324324oneYear :: Int
325325oneYear = 60 * 60 * 24 * 365
326326
327−data FileLookup = FLFolder Folder | FLFile File | FLDoesNotExist -- FIXME remove
327+type FileLookup = Maybe (Either Folder File)
328328
329329data Folder = Folder
330330 { folderName :: T.Text
@@ -383,7 +383,7 @@ fileSystemLookup prefix pieces = do
383383 if fe
384384 then do
385385 fs <- getFileStatus fp
386− return $ FLFile File
386+ return $ Just $ Right File
387387 { fileGetSize = fromIntegral $ fileSize fs
388388 , fileToResponse = \s h -> W.ResponseFile s h fp Nothing
389389 , fileName = piecePretty $ last pieces
@@ -420,8 +420,8 @@ fileSystemLookup prefix pieces = do
420420 , fileGetModified = Just $ modificationTime fs
421421 }
422422 else return $ Left $ Folder name' [])
423− return $ FLFolder $ Folder (error "413") entries
424− else return FLDoesNotExist
423+ return $ Just $ Left $ Folder (error "413") entries
424+ else return Nothing
425425
426426type Embedded = Map.Map T.Text EmbeddedEntry
427427
@@ -432,19 +432,19 @@ embeddedLookup root pieces =
432432 return $ elookup "<root>" (map piecePretty pieces) root
433433 where
434434 elookup :: T.Text -> [T.Text] -> Embedded -> FileLookup
435− elookup p [] x = FLFolder $ Folder p $ map toEntry $ Map.toList x
435+ elookup p [] x = Just $ Left $ Folder p $ map toEntry $ Map.toList x
436436 elookup p [""] x = elookup p [] x
437437 elookup _ (p:ps) x =
438438 case Map.lookup p x of
439− Nothing -> FLDoesNotExist
439+ Nothing -> Nothing
440440 Just (EEFile f) ->
441441 case ps of
442− [] -> FLFile $ bsToFile p f
443− _ -> FLDoesNotExist
442+ [] -> Just $ Right $ bsToFile p f
443+ _ -> Nothing
444444 Just (EEFolder y) -> elookup p ps y
445445
446446toEntry :: (T.Text, EmbeddedEntry) -> Either Folder File
447−toEntry (name, EEFolder e) = Left $ Folder name (error "toEntry")
447+toEntry (name, EEFolder e) = Left $ Folder name []
448448toEntry (name, EEFile bs) = Right $ File
449449 { fileGetSize = S8.length bs
450450 , fileToResponse = \s h -> W.ResponseBuilder s h $ fromByteString bs