merging sqlite and bs branches
Since the sqlite branch uses blobs extensively, there are some performance benefits, ByteStrings now get stored and retrieved w/o conversion in some cases like in Database.Export.
This commit is contained in:
commit
2f9a80d803
266 changed files with 2860 additions and 1325 deletions
|
@ -84,8 +84,8 @@ updateSymlinks :: Annex ()
|
|||
updateSymlinks = do
|
||||
showAction "updating symlinks"
|
||||
top <- fromRepo Git.repoPath
|
||||
(files, cleanup) <- inRepo $ LsFiles.inRepo [top]
|
||||
forM_ files fixlink
|
||||
(files, cleanup) <- inRepo $ LsFiles.inRepo [toRawFilePath top]
|
||||
forM_ files (fixlink . fromRawFilePath)
|
||||
void $ liftIO cleanup
|
||||
where
|
||||
fixlink f = do
|
||||
|
@ -134,7 +134,7 @@ oldlog2key l
|
|||
where
|
||||
len = length l - 4
|
||||
k = readKey1 (take len l)
|
||||
sane = (not . S.null $ keyName k) && (not . S.null $ formatKeyVariety $ keyVariety k)
|
||||
sane = (not . S.null $ fromKey keyName k) && (not . S.null $ formatKeyVariety $ fromKey keyVariety k)
|
||||
|
||||
-- WORM backend keys: "WORM:mtime:size:filename"
|
||||
-- all the rest: "backend:key"
|
||||
|
@ -145,7 +145,7 @@ oldlog2key l
|
|||
readKey1 :: String -> Key
|
||||
readKey1 v
|
||||
| mixup = fromJust $ deserializeKey $ intercalate ":" $ Prelude.tail bits
|
||||
| otherwise = stubKey
|
||||
| otherwise = mkKey $ \d -> d
|
||||
{ keyName = encodeBS n
|
||||
, keyVariety = parseKeyVariety (encodeBS b)
|
||||
, keySize = s
|
||||
|
@ -165,12 +165,16 @@ readKey1 v
|
|||
mixup = wormy && isUpper (Prelude.head $ bits !! 1)
|
||||
|
||||
showKey1 :: Key -> String
|
||||
showKey1 Key { keyName = n , keyVariety = v, keySize = s, keyMtime = t } =
|
||||
intercalate ":" $ filter (not . null) [b, showifhere t, showifhere s, decodeBS n]
|
||||
showKey1 k = intercalate ":" $ filter (not . null)
|
||||
[b, showifhere t, showifhere s, decodeBS n]
|
||||
where
|
||||
showifhere Nothing = ""
|
||||
showifhere (Just x) = show x
|
||||
b = decodeBS $ formatKeyVariety v
|
||||
n = fromKey keyName k
|
||||
v = fromKey keyVariety k
|
||||
s = fromKey keySize k
|
||||
t = fromKey keyMtime k
|
||||
|
||||
keyFile1 :: Key -> FilePath
|
||||
keyFile1 key = replace "/" "%" $ replace "%" "&s" $ replace "&" "&a" $ showKey1 key
|
||||
|
@ -194,7 +198,7 @@ lookupFile1 file = do
|
|||
Right l -> makekey l
|
||||
where
|
||||
getsymlink = takeFileName <$> readSymbolicLink file
|
||||
makekey l = case maybeLookupBackendVariety (keyVariety k) of
|
||||
makekey l = case maybeLookupBackendVariety (fromKey keyVariety k) of
|
||||
Nothing -> do
|
||||
unless (null kname || null bname ||
|
||||
not (isLinkToAnnex (toRawFilePath l))) $
|
||||
|
@ -203,8 +207,8 @@ lookupFile1 file = do
|
|||
Just backend -> return $ Just (k, backend)
|
||||
where
|
||||
k = fileKey1 l
|
||||
bname = decodeBS (formatKeyVariety (keyVariety k))
|
||||
kname = decodeBS (keyName k)
|
||||
bname = decodeBS (formatKeyVariety (fromKey keyVariety k))
|
||||
kname = decodeBS (fromKey keyName k)
|
||||
skip = "skipping " ++ file ++
|
||||
" (unknown backend " ++ bname ++ ")"
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ upgrade = do
|
|||
e <- liftIO $ doesDirectoryExist old
|
||||
when e $ do
|
||||
config <- Annex.getGitConfig
|
||||
mapM_ (\(k, f) -> inject f $ locationLogFile config k) =<< locationLogs
|
||||
mapM_ (\(k, f) -> inject f $ fromRawFilePath $ locationLogFile config k) =<< locationLogs
|
||||
mapM_ (\f -> inject f f) =<< logFiles old
|
||||
|
||||
saveState False
|
||||
|
@ -76,13 +76,13 @@ locationLogs = do
|
|||
where
|
||||
tryDirContents d = catchDefaultIO [] $ dirContents d
|
||||
islogfile f = maybe Nothing (\k -> Just (k, f)) $
|
||||
locationLogFileKey f
|
||||
locationLogFileKey (toRawFilePath f)
|
||||
|
||||
inject :: FilePath -> FilePath -> Annex ()
|
||||
inject source dest = do
|
||||
old <- fromRepo olddir
|
||||
new <- liftIO (readFile $ old </> source)
|
||||
Annex.Branch.change dest $ \prev ->
|
||||
Annex.Branch.change (toRawFilePath dest) $ \prev ->
|
||||
encodeBL $ unlines $ nub $ lines (decodeBL prev) ++ lines new
|
||||
|
||||
logFiles :: FilePath -> Annex [FilePath]
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Upgrade.V5 where
|
||||
|
||||
import Annex.Common
|
||||
|
@ -106,7 +108,7 @@ convertDirect = do
|
|||
upgradeDirectWorkTree :: Annex ()
|
||||
upgradeDirectWorkTree = do
|
||||
top <- fromRepo Git.repoPath
|
||||
(l, clean) <- inRepo $ Git.LsFiles.stagedDetails [top]
|
||||
(l, clean) <- inRepo $ Git.LsFiles.stagedDetails [toRawFilePath top]
|
||||
forM_ l go
|
||||
void $ liftIO clean
|
||||
where
|
||||
|
@ -119,11 +121,11 @@ upgradeDirectWorkTree = do
|
|||
Just k -> do
|
||||
stagePointerFile f Nothing =<< hashPointerFile k
|
||||
ifM (isJust <$> getAnnexLinkTarget f)
|
||||
( writepointer f k
|
||||
, fromdirect f k
|
||||
( writepointer (fromRawFilePath f) k
|
||||
, fromdirect (fromRawFilePath f) k
|
||||
)
|
||||
Database.Keys.addAssociatedFile k
|
||||
=<< inRepo (toTopFilePath f)
|
||||
=<< inRepo (toTopFilePath (fromRawFilePath f))
|
||||
go _ = noop
|
||||
|
||||
fromdirect f k = ifM (Direct.goodContent k f)
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Upgrade.V5.Direct (
|
||||
switchHEADBack,
|
||||
setIndirect,
|
||||
|
@ -44,12 +46,12 @@ setIndirect = do
|
|||
-- unset it when enabling direct mode, caching in
|
||||
-- core.indirect-worktree
|
||||
moveconfig indirectworktree coreworktree
|
||||
setConfig (ConfigKey Git.Config.coreBare) val
|
||||
setConfig Git.Config.coreBare val
|
||||
moveconfig src dest = getConfigMaybe src >>= \case
|
||||
Nothing -> noop
|
||||
Just wt -> do
|
||||
unsetConfig src
|
||||
setConfig dest wt
|
||||
setConfig dest (fromConfigValue wt)
|
||||
reloadConfig
|
||||
|
||||
{- Converts a directBranch back to the original branch.
|
||||
|
|
|
@ -95,11 +95,11 @@ removeOldDb getdb = do
|
|||
populateKeysDb :: Annex ()
|
||||
populateKeysDb = do
|
||||
top <- fromRepo Git.repoPath
|
||||
(l, cleanup) <- inRepo $ LsFiles.inodeCaches [top]
|
||||
(l, cleanup) <- inRepo $ LsFiles.inodeCaches [toRawFilePath top]
|
||||
forM_ l $ \case
|
||||
(_f, Nothing) -> giveup "Unable to parse git ls-files --debug output while upgrading git-annex sqlite databases."
|
||||
(f, Just ic) -> unlessM (liftIO $ isSymbolicLink <$> getSymbolicLinkStatus f) $ do
|
||||
catKeyFile f >>= \case
|
||||
catKeyFile (toRawFilePath f) >>= \case
|
||||
Nothing -> noop
|
||||
Just k -> do
|
||||
topf <- inRepo $ toTopFilePath f
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue