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
|
ms <- liftIO $ catchMaybeIO $ R.getFileStatus src
|
||||||
mcache <- maybe (pure Nothing) (liftIO . toInodeCache delta src) ms
|
mcache <- maybe (pure Nothing) (liftIO . toInodeCache delta src) ms
|
||||||
case (mcache, inodeCache source) of
|
case (mcache, inodeCache source) of
|
||||||
(_, Nothing) -> go k mcache ms
|
(_, Nothing) -> go k mcache
|
||||||
(Just newc, Just c) | compareStrong c newc -> go k mcache ms
|
(Just newc, Just c) | compareStrong c newc -> go k mcache
|
||||||
_ -> failure "changed while it was being added"
|
_ -> failure "changed while it was being added"
|
||||||
where
|
where
|
||||||
go key mcache (Just s)
|
go key mcache
|
||||||
| lockingFile cfg = golocked key mcache s
|
| lockingFile cfg = golocked key mcache
|
||||||
| otherwise = gounlocked key mcache s
|
| otherwise = gounlocked key mcache
|
||||||
go _ _ Nothing = failure "failed to generate a key"
|
|
||||||
|
|
||||||
golocked key mcache s =
|
golocked key mcache =
|
||||||
tryNonAsync (moveAnnex key naf (contentLocation source)) >>= \case
|
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"
|
Right False -> giveup "failed to add content to annex"
|
||||||
Left e -> restoreFile (keyFilename source) key e
|
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.
|
-- file, so provide it nothing.
|
||||||
naf = AssociatedFile Nothing
|
naf = AssociatedFile Nothing
|
||||||
|
|
||||||
gounlocked key (Just cache) s = do
|
gounlocked key (Just cache) = do
|
||||||
-- Remove temp directory hard link first because
|
-- Remove temp directory hard link first because
|
||||||
-- linkToAnnex falls back to copying if a file
|
-- linkToAnnex falls back to copying if a file
|
||||||
-- already has a hard link.
|
-- 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"
|
LinkAnnexFailed -> failure "failed to link to annex"
|
||||||
lar -> do
|
lar -> do
|
||||||
finishIngestUnlocked' key source restage (Just lar)
|
finishIngestUnlocked' key source restage (Just lar)
|
||||||
success key (Just cache) s
|
success key (Just cache)
|
||||||
gounlocked _ _ _ = failure "failed statting file"
|
gounlocked _ _ = failure "failed statting file"
|
||||||
|
|
||||||
success k mcache s = do
|
success k mcache = do
|
||||||
genMetaData k (keyFilename source) s
|
genMetaData k (keyFilename source) (fmap inodeCacheToMtime mcache)
|
||||||
return (Just k, mcache)
|
return (Just k, mcache)
|
||||||
|
|
||||||
failure msg = do
|
failure msg = do
|
||||||
|
|
|
@ -37,8 +37,8 @@ import Data.Time.Clock.POSIX
|
||||||
-
|
-
|
||||||
- Also, can generate new metadata, if configured to do so.
|
- Also, can generate new metadata, if configured to do so.
|
||||||
-}
|
-}
|
||||||
genMetaData :: Key -> RawFilePath -> FileStatus -> Annex ()
|
genMetaData :: Key -> RawFilePath -> Maybe POSIXTime -> Annex ()
|
||||||
genMetaData key file status = do
|
genMetaData key file mmtime = do
|
||||||
catKeyFileHEAD file >>= \case
|
catKeyFileHEAD file >>= \case
|
||||||
Nothing -> noop
|
Nothing -> noop
|
||||||
Just oldkey ->
|
Just oldkey ->
|
||||||
|
@ -47,11 +47,14 @@ genMetaData key file status = do
|
||||||
-- preserve any metadata already on key.
|
-- preserve any metadata already on key.
|
||||||
whenM (copyMetaData oldkey key <&&> (not <$> onlydatemeta oldkey)) $
|
whenM (copyMetaData oldkey key <&&> (not <$> onlydatemeta oldkey)) $
|
||||||
warncopied
|
warncopied
|
||||||
whenM (annexGenMetaData <$> Annex.getGitConfig) $ do
|
whenM (annexGenMetaData <$> Annex.getGitConfig) $
|
||||||
old <- getCurrentMetaData key
|
case mmtime of
|
||||||
addMetaData key (dateMetaData mtime old)
|
Just mtime -> do
|
||||||
|
old <- getCurrentMetaData key
|
||||||
|
addMetaData key $
|
||||||
|
dateMetaData (posixSecondsToUTCTime mtime) old
|
||||||
|
Nothing -> noop
|
||||||
where
|
where
|
||||||
mtime = posixSecondsToUTCTime $ realToFrac $ modificationTime status
|
|
||||||
warncopied = warning $
|
warncopied = warning $
|
||||||
"Copied metadata from old version of " ++ fromRawFilePath file ++ " to new version. " ++
|
"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
|
"If you don't want this copied metadata, run: git annex metadata --remove-all " ++ fromRawFilePath file
|
||||||
|
|
Loading…
Reference in a new issue