Skip to content

Commit

Permalink
make sure caches do not overlap for different years
Browse files Browse the repository at this point in the history
  • Loading branch information
mstksg committed Dec 9, 2018
1 parent 42daa47 commit 56c77c4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Version 0.1.2.X

<https://github.com/mstksg/advent-of-code-api/releases/tag/v0.1.2.2>

* *December 8, 2018*: *BUGFIX* Fix cache directory to separate by year

<https://github.com/mstksg/advent-of-code-api/releases/tag/v0.1.2.3>

Version 0.1.2.0
---------------

Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: advent-of-code-api
version: 0.1.2.2
version: 0.1.2.3
github: "mstksg/advent-of-code-api"
license: BSD3
author: "Justin Le"
Expand Down
9 changes: 5 additions & 4 deletions src/Advent.hs
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,12 @@ apiCurl sess = \case
-- | Cache file for a given 'AoC' command
apiCache
:: Maybe String -- ^ session key
-> Integer -- ^ year
-> AoC a
-> Maybe FilePath
apiCache sess = \case
AoCPrompt d -> Just $ printf "prompt/%02d.html" (dayInt d)
AoCInput d -> Just $ printf "input/%s%02d.txt" keyDir (dayInt d)
apiCache sess yr = \case
AoCPrompt d -> Just $ printf "prompt/%04d/%02d.html" yr (dayInt d)
AoCInput d -> Just $ printf "input/%s%04d/%02d.txt" keyDir yr (dayInt d)
AoCSubmit{} -> Nothing
where
keyDir = case sess of
Expand All @@ -309,7 +310,7 @@ runAoC AoCOpts{..} a = do
Just c -> pure (Nothing, c)
Nothing -> (Just _aSessionKey,) . (</> "advent-of-code-api") <$> getTemporaryDirectory

let cacher = case apiCache keyMayb a of
let cacher = case apiCache keyMayb _aYear a of
Nothing -> id
Just fp -> cacheing (cacheDir </> fp) $
if _aForce
Expand Down

0 comments on commit 56c77c4

Please sign in to comment.