Commit 7b91593d authored by Armin Bernstetter's avatar Armin Bernstetter
Browse files

compare versions correctly. Feels a bit too hacky/verbose somehow

parent b409752f
......@@ -12,6 +12,7 @@ import Common
import Control.Exception
import Control.Monad
import Control.Monad.Extra
import Data.List.Split as Split
import Exception
import System.Directory
import System.Environment
......@@ -29,15 +30,17 @@ deckerResourceDir =
getOldResources :: IO [FilePath]
getOldResources = do
dir <- takeDirectory <$> deckerResourceDir
dir <- getXdgDirectory XdgData []
files <- listDirectory dir
return $ map (dir </>) $ filter oldVersion files
where
deckerRegex = "decker-([0-9]+[.][0-9]+[.][0-9]+)-" :: String
deckerRegex = "decker-([0-9]+)[.]([0-9]+)[.]([0-9]+)-" :: String
convert = map (read :: String -> Int)
current = convert (splitOn "." deckerVersion)
oldVersion name =
case getAllTextSubmatches (name =~ deckerRegex) :: [String] of
[] -> False
_:v:vs -> v < deckerVersion
_:x:y:z:vs -> convert [x, y, z] < current
getResourceString :: FilePath -> IO String
getResourceString path = do
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment