directory, webdav: Fix bug introduced in version 4.20131002 that caused the chunkcount file to not be written. Work around repositories without such a file, so files can still be retreived from them.
This commit is contained in:
parent
06ea92282f
commit
5756636486
5 changed files with 42 additions and 7 deletions
|
@ -109,9 +109,13 @@ withCheckedFiles check (Just _) d k a = go $ locations d k
|
||||||
ifM (check chunkcount)
|
ifM (check chunkcount)
|
||||||
( do
|
( do
|
||||||
chunks <- listChunks f <$> readFile chunkcount
|
chunks <- listChunks f <$> readFile chunkcount
|
||||||
ifM (and <$> mapM check chunks)
|
ifM (allM check chunks)
|
||||||
( a chunks , return False )
|
( a chunks , return False )
|
||||||
, go fs
|
, do
|
||||||
|
chunks <- probeChunks f check
|
||||||
|
if null chunks
|
||||||
|
then go fs
|
||||||
|
else a chunks
|
||||||
)
|
)
|
||||||
|
|
||||||
withStoredFiles :: ChunkSize -> FilePath -> Key -> ([FilePath] -> IO Bool) -> IO Bool
|
withStoredFiles :: ChunkSize -> FilePath -> Key -> ([FilePath] -> IO Bool) -> IO Bool
|
||||||
|
|
|
@ -43,6 +43,10 @@ type ChunkExt = String
|
||||||
chunkCount :: ChunkExt
|
chunkCount :: ChunkExt
|
||||||
chunkCount = ".chunkcount"
|
chunkCount = ".chunkcount"
|
||||||
|
|
||||||
|
{- An infinite stream of extensions to use for chunks. -}
|
||||||
|
chunkStream :: [ChunkExt]
|
||||||
|
chunkStream = map (\n -> ".chunk" ++ show n) [1 :: Integer ..]
|
||||||
|
|
||||||
{- Parses the String from the chunkCount file, and returns the files that
|
{- Parses the String from the chunkCount file, and returns the files that
|
||||||
- are used to store the chunks. -}
|
- are used to store the chunks. -}
|
||||||
listChunks :: FilePath -> String -> [FilePath]
|
listChunks :: FilePath -> String -> [FilePath]
|
||||||
|
@ -50,9 +54,22 @@ listChunks basedest chunkcount = take count $ map (basedest ++) chunkStream
|
||||||
where
|
where
|
||||||
count = fromMaybe 0 $ readish chunkcount
|
count = fromMaybe 0 $ readish chunkcount
|
||||||
|
|
||||||
{- An infinite stream of extensions to use for chunks. -}
|
{- For use when there is no chunkCount file; uses the action to find
|
||||||
chunkStream :: [ChunkExt]
|
- chunks, and returns them, or Nothing if none found. Relies on
|
||||||
chunkStream = map (\n -> ".chunk" ++ show n) [1 :: Integer ..]
|
- storeChunks's finalizer atomically moving the chunks into place once all
|
||||||
|
- are written.
|
||||||
|
-
|
||||||
|
- This is only needed to work around a bug that caused the chunkCount file
|
||||||
|
- not to be written.
|
||||||
|
-}
|
||||||
|
probeChunks :: FilePath -> (FilePath -> IO Bool) -> IO [FilePath]
|
||||||
|
probeChunks basedest check = go [] $ map (basedest ++) chunkStream
|
||||||
|
where
|
||||||
|
go l [] = return (reverse l)
|
||||||
|
go l (c:cs) = ifM (check c)
|
||||||
|
( go (c:l) cs
|
||||||
|
, go l []
|
||||||
|
)
|
||||||
|
|
||||||
{- Given the base destination to use to store a value,
|
{- Given the base destination to use to store a value,
|
||||||
- generates a stream of temporary destinations (just one when not chunking)
|
- generates a stream of temporary destinations (just one when not chunking)
|
||||||
|
|
|
@ -198,8 +198,14 @@ withStoredFiles
|
||||||
withStoredFiles r k baseurl user pass onerr a
|
withStoredFiles r k baseurl user pass onerr a
|
||||||
| isJust $ chunkSize $ config r = do
|
| isJust $ chunkSize $ config r = do
|
||||||
let chunkcount = keyurl ++ chunkCount
|
let chunkcount = keyurl ++ chunkCount
|
||||||
maybe (onerr chunkcount) (a . listChunks keyurl . L8.toString)
|
v <- davGetUrlContent chunkcount user pass
|
||||||
=<< davGetUrlContent chunkcount user pass
|
case v of
|
||||||
|
Just s -> a $ listChunks keyurl $ L8.toString s
|
||||||
|
Nothing -> do
|
||||||
|
chunks <- probeChunks keyurl $ \u -> (== Right True) <$> davUrlExists u user pass
|
||||||
|
if null chunks
|
||||||
|
then onerr chunkcount
|
||||||
|
else a chunks
|
||||||
| otherwise = a [keyurl]
|
| otherwise = a [keyurl]
|
||||||
where
|
where
|
||||||
keyurl = davLocation baseurl k ++ keyFile k
|
keyurl = davLocation baseurl k ++ keyFile k
|
||||||
|
|
3
debian/changelog
vendored
3
debian/changelog
vendored
|
@ -4,6 +4,9 @@ git-annex (4.20131025) UNRELEASED; urgency=low
|
||||||
scan, to avoid contending with the user's desktop login process.
|
scan, to avoid contending with the user's desktop login process.
|
||||||
* webapp: When setting up a bare shared repository, enable non-fast-forward
|
* webapp: When setting up a bare shared repository, enable non-fast-forward
|
||||||
pushes.
|
pushes.
|
||||||
|
* directory, webdav: Fix bug introduced in version 4.20131002 that
|
||||||
|
caused the chunkcount file to not be written. Work around repositories
|
||||||
|
without such a file, so files can still be retreived from them.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Sat, 26 Oct 2013 12:11:48 -0400
|
-- Joey Hess <joeyh@debian.org> Sat, 26 Oct 2013 12:11:48 -0400
|
||||||
|
|
||||||
|
|
|
@ -67,3 +67,8 @@ fsck webdav again, now all is fine ("fixing location log"):
|
||||||
10672 open("/media/1und1/git-annex/dcf/85a/GPGHMACSHA1--10ff9e1cc8191235670c2fd95375bccf62004f33/GPGHMACSHA1--10ff9e1cc8191235670c2fd95375bccf62004f33.chunk1", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_LARGEFILE) = 20
|
10672 open("/media/1und1/git-annex/dcf/85a/GPGHMACSHA1--10ff9e1cc8191235670c2fd95375bccf62004f33/GPGHMACSHA1--10ff9e1cc8191235670c2fd95375bccf62004f33.chunk1", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_LARGEFILE) = 20
|
||||||
# End of transcript or log.
|
# End of transcript or log.
|
||||||
"""]]
|
"""]]
|
||||||
|
|
||||||
|
> There was a bug that caused it not to write the chunkcount file.
|
||||||
|
> I have fixed it, and put in a workaround so fsck, etc, will
|
||||||
|
> see that the file is stored on the remote despite there being no
|
||||||
|
> chunkcount file present. [[done]] --[[Joey]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue