module Unison.Codebase.SqliteCodebase.Paths
( codebasePath,
makeCodebasePath,
makeCodebaseDirPath,
backupCodebasePath,
lockfilePath,
)
where
import Data.Time (NominalDiffTime)
import System.FilePath ((</>))
import U.Codebase.Sqlite.DbId (SchemaVersion (SchemaVersion))
import Unison.Codebase (CodebasePath)
codebasePath :: FilePath
codebasePath :: [Char]
codebasePath = [Char]
".unison" [Char] -> [Char] -> [Char]
</> [Char]
"v2" [Char] -> [Char] -> [Char]
</> [Char]
"unison.sqlite3"
makeCodebasePath :: CodebasePath -> FilePath
makeCodebasePath :: [Char] -> [Char]
makeCodebasePath [Char]
root = [Char] -> [Char]
makeCodebaseDirPath [Char]
root [Char] -> [Char] -> [Char]
</> [Char]
"unison.sqlite3"
lockfilePath :: CodebasePath -> FilePath
lockfilePath :: [Char] -> [Char]
lockfilePath [Char]
root = [Char] -> [Char]
makeCodebaseDirPath [Char]
root [Char] -> [Char] -> [Char]
</> [Char]
"unison.lockfile"
makeCodebaseDirPath :: CodebasePath -> FilePath
makeCodebaseDirPath :: [Char] -> [Char]
makeCodebaseDirPath [Char]
root = [Char]
root [Char] -> [Char] -> [Char]
</> [Char]
".unison" [Char] -> [Char] -> [Char]
</> [Char]
"v2"
backupCodebasePath :: SchemaVersion -> NominalDiffTime -> FilePath
backupCodebasePath :: SchemaVersion -> NominalDiffTime -> [Char]
backupCodebasePath (SchemaVersion Word64
schemaVersion) NominalDiffTime
now =
[Char]
codebasePath [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
".v" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Word64 -> [Char]
forall a. Show a => a -> [Char]
show Word64
schemaVersion [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"." [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show @Int (NominalDiffTime -> Int
forall b. Integral b => NominalDiffTime -> b
forall a b. (RealFrac a, Integral b) => a -> b
floor NominalDiffTime
now)