Skip cached metadata when url starts with file://

This commit is contained in:
Julian Ospald 2021-08-07 09:54:26 +02:00
parent 88d1d19f55
commit e903aeb555
Signed by: hasufell
GPG Key ID: 3786C5262ECB4A3F

View File

@ -224,18 +224,19 @@ Consider removing "#{yaml}" manually.|]))
() ()
smartDl uri' = do smartDl uri' = do
json_file <- lift $ yamlFromCache uri' json_file <- lift $ yamlFromCache uri'
let scheme = view (uriSchemeL' % schemeBSL') uri'
e <- liftIO $ doesFileExist json_file e <- liftIO $ doesFileExist json_file
currentTime <- liftIO getCurrentTime currentTime <- liftIO getCurrentTime
if e
then do
accessTime <- liftIO $ getAccessTime json_file
-- access time won't work on most linuxes, but we can try regardless if | scheme == "file" -> dlWithMod currentTime json_file
when ((utcTimeToPOSIXSeconds currentTime - utcTimeToPOSIXSeconds accessTime) > 300) $ | e -> do
-- no access in last 5 minutes, re-check upstream mod time accessTime <- liftIO $ getAccessTime json_file
dlWithMod currentTime json_file
else -- access time won't work on most linuxes, but we can try regardless
dlWithMod currentTime json_file when ((utcTimeToPOSIXSeconds currentTime - utcTimeToPOSIXSeconds accessTime) > 300) $
-- no access in last 5 minutes, re-check upstream mod time
dlWithMod currentTime json_file
| otherwise -> dlWithMod currentTime json_file
where where
dlWithMod modTime json_file = do dlWithMod modTime json_file = do
let (dir, fn) = splitFileName json_file let (dir, fn) = splitFileName json_file