fix error message
Was "failed to generate a key" when key generation did not fail
(it never does anymore) but the actual problem was it failed to stat
the source file, perhaps due to it being deleted while the key was being
generated.
A user reported this, in a comment I followed up on in
262400fe04
, although I don't know
what they did to trigger the error message.
This commit is contained in:
parent
262400fe04
commit
6242b35c33
2 changed files with 21 additions and 19 deletions
|
@ -184,18 +184,17 @@ ingest' preferredbackend meterupdate (Just (LockedDown cfg source)) mk restage =
|
|||
ms <- liftIO $ catchMaybeIO $ R.getFileStatus src
|
||||
mcache <- maybe (pure Nothing) (liftIO . toInodeCache delta src) ms
|
||||
case (mcache, inodeCache source) of
|
||||
(_, Nothing) -> go k mcache ms
|
||||
(Just newc, Just c) | compareStrong c newc -> go k mcache ms
|
||||
(_, Nothing) -> go k mcache
|
||||
(Just newc, Just c) | compareStrong c newc -> go k mcache
|
||||
_ -> failure "changed while it was being added"
|
||||
where
|
||||
go key mcache (Just s)
|
||||
| lockingFile cfg = golocked key mcache s
|
||||
| otherwise = gounlocked key mcache s
|
||||
go _ _ Nothing = failure "failed to generate a key"
|
||||
go key mcache
|
||||
| lockingFile cfg = golocked key mcache
|
||||
| otherwise = gounlocked key mcache
|
||||
|
||||
golocked key mcache s =
|
||||
golocked key mcache =
|
||||
tryNonAsync (moveAnnex key naf (contentLocation source)) >>= \case
|
||||
Right True -> success key mcache s
|
||||
Right True -> success key mcache
|
||||
Right False -> giveup "failed to add content to annex"
|
||||
Left e -> restoreFile (keyFilename source) key e
|
||||
|
||||
|
@ -205,7 +204,7 @@ ingest' preferredbackend meterupdate (Just (LockedDown cfg source)) mk restage =
|
|||
-- file, so provide it nothing.
|
||||
naf = AssociatedFile Nothing
|
||||
|
||||
gounlocked key (Just cache) s = do
|
||||
gounlocked key (Just cache) = do
|
||||
-- Remove temp directory hard link first because
|
||||
-- linkToAnnex falls back to copying if a file
|
||||
-- already has a hard link.
|
||||
|
@ -215,11 +214,11 @@ ingest' preferredbackend meterupdate (Just (LockedDown cfg source)) mk restage =
|
|||
LinkAnnexFailed -> failure "failed to link to annex"
|
||||
lar -> do
|
||||
finishIngestUnlocked' key source restage (Just lar)
|
||||
success key (Just cache) s
|
||||
gounlocked _ _ _ = failure "failed statting file"
|
||||
success key (Just cache)
|
||||
gounlocked _ _ = failure "failed statting file"
|
||||
|
||||
success k mcache s = do
|
||||
genMetaData k (keyFilename source) s
|
||||
success k mcache = do
|
||||
genMetaData k (keyFilename source) (fmap inodeCacheToMtime mcache)
|
||||
return (Just k, mcache)
|
||||
|
||||
failure msg = do
|
||||
|
|
|
@ -37,8 +37,8 @@ import Data.Time.Clock.POSIX
|
|||
-
|
||||
- Also, can generate new metadata, if configured to do so.
|
||||
-}
|
||||
genMetaData :: Key -> RawFilePath -> FileStatus -> Annex ()
|
||||
genMetaData key file status = do
|
||||
genMetaData :: Key -> RawFilePath -> Maybe POSIXTime -> Annex ()
|
||||
genMetaData key file mmtime = do
|
||||
catKeyFileHEAD file >>= \case
|
||||
Nothing -> noop
|
||||
Just oldkey ->
|
||||
|
@ -47,11 +47,14 @@ genMetaData key file status = do
|
|||
-- preserve any metadata already on key.
|
||||
whenM (copyMetaData oldkey key <&&> (not <$> onlydatemeta oldkey)) $
|
||||
warncopied
|
||||
whenM (annexGenMetaData <$> Annex.getGitConfig) $ do
|
||||
old <- getCurrentMetaData key
|
||||
addMetaData key (dateMetaData mtime old)
|
||||
whenM (annexGenMetaData <$> Annex.getGitConfig) $
|
||||
case mmtime of
|
||||
Just mtime -> do
|
||||
old <- getCurrentMetaData key
|
||||
addMetaData key $
|
||||
dateMetaData (posixSecondsToUTCTime mtime) old
|
||||
Nothing -> noop
|
||||
where
|
||||
mtime = posixSecondsToUTCTime $ realToFrac $ modificationTime status
|
||||
warncopied = warning $
|
||||
"Copied metadata from old version of " ++ fromRawFilePath file ++ " to new version. " ++
|
||||
"If you don't want this copied metadata, run: git annex metadata --remove-all " ++ fromRawFilePath file
|
||||
|
|
Loading…
Reference in a new issue