Commit 2d1e0a47 authored by Jan-Philipp Stauffert's avatar Jan-Philipp Stauffert
Browse files

Merge branch '80-delete-old-resources' into 'master'

Resolve "Delete old resource folders"

Closes #80

See merge request decker/decker!48
parents c315ffe4 7874e6e0
......@@ -59,8 +59,7 @@ main = do
" (branch: " ++
deckerGitBranch ++
", commit: " ++
deckerGitCommitId ++
", tag: " ++ deckerGitVersionTag ++ ")"
deckerGitCommitId ++ ", tag: " ++ deckerGitVersionTag ++ ")"
putNormal $ "pandoc version " ++ pandocVersion
putNormal $ "pandoc-types version " ++ showVersion pandocTypesVersion
--
......@@ -166,6 +165,8 @@ main = do
phony "clean" $ do
removeFilesAfter (directories ^. public) ["//"]
removeFilesAfter (directories ^. project) cruft
old <- liftIO getOldResources
forM_ old $ \dir -> removeFilesAfter dir ["//"]
when isDevelopmentVersion $
removeFilesAfter (directories ^. appData) ["//"]
--
......
......@@ -2,6 +2,7 @@
module Resources
( extractResources
, getResourceString
, getOldResources
, deckerResourceDir
, writeExampleProject
, copyDir
......@@ -11,12 +12,14 @@ import Common
import Control.Exception
import Control.Monad
import Control.Monad.Extra
import Data.List.Split (splitOn)
import Exception
import System.Directory
import System.Environment
import System.Exit
import System.FilePath
import System.Process
import Text.Regex.TDFA
deckerResourceDir :: IO FilePath
deckerResourceDir =
......@@ -25,6 +28,22 @@ deckerResourceDir =
("decker" ++
"-" ++ deckerVersion ++ "-" ++ deckerGitBranch ++ "-" ++ deckerGitCommitId)
-- | Get the absolute paths of resource folders
-- with version numbers older than the current one
getOldResources :: IO [FilePath]
getOldResources = do
dir <- getXdgDirectory XdgData []
files <- listDirectory dir
return $ map (dir </>) $ filter oldVersion files
where
convert = map (read :: String -> Int)
currentVersion = convert (splitOn "." deckerVersion)
deckerRegex = "decker-([0-9]+)[.]([0-9]+)[.]([0-9]+)-" :: String
oldVersion name =
case getAllTextSubmatches (name =~ deckerRegex) :: [String] of
[] -> False
_:x:y:z:_ -> convert [x, y, z] < currentVersion
getResourceString :: FilePath -> IO String
getResourceString path = do
dataDir <- deckerResourceDir
......
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