import: Avoid using some strange names for temporary keys

The ContentIdentifier can contain almost anything, so could have characters
that are not fit for the filesystem, or might be longer than a key usually
is, or contain a newline, or .... genKeyName deals with those problems.

This should not present a back-compat issue, because this is a temporary
key used while downloading the imported file, before the real key for it
can be generated.
This commit is contained in:
Joey Hess 2020-06-11 16:07:36 -04:00
parent 0017d9a347
commit 8a7c615a8f
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 26 additions and 1 deletions

View file

@ -50,6 +50,7 @@ import Utility.Matcher (isEmpty)
import qualified Database.Export as Export
import qualified Database.ContentIdentifier as CIDDb
import qualified Logs.ContentIdentifier as CIDLog
import Backend.Utilities
import Control.Concurrent.STM
import qualified Data.Map.Strict as M
@ -404,7 +405,7 @@ downloadImport remote importtreeconfig importablecontents = do
- content, before generating its real key. -}
importKey :: ContentIdentifier -> Integer -> Key
importKey (ContentIdentifier cid) size = mkKey $ \k -> k
{ keyName = cid
{ keyName = genKeyName (decodeBS cid)
, keyVariety = OtherKey "CID"
, keySize = Just size
}

View file

@ -32,6 +32,7 @@ git-annex (8.20200523) UNRELEASED; urgency=medium
* Avoid creating the keys database during init when there are no unlocked
files, to prevent init failing when sqlite does not work in the
filesystem.
* import: Avoid using some strange names for temporary keys.
-- Joey Hess <id@joeyh.name> Tue, 26 May 2020 10:20:52 -0400

View file

@ -0,0 +1,23 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2020-06-11T19:46:25Z"
content="""
Is this about HOME being on the FS, or about git-annex test being run
inside the FS?
It looks to me to be the latter, since the file it fails
on is in .git/annex/tmp
2020-06-10T16:02:41.4916599Z .git/annex/tmp/CID-s16--24892 16 1591804960 : openBinaryFile: invalid argument (Invalid argument)
Might this filesystem have trouble with filenames with spaces,
particularly trailing spaces? That's kind of weird, and I've changed it so
it won't contain those spaces.
Also this line just after the FAIL seems relevant. (I suspect
the log might not have every line in the right order, like maybe stdout and
stderr are being read independantly and written to the log.)
2020-06-10T16:02:41.5278208Z Exception: import: getSymbolicLinkStatus: does not exist (No such file or directory)
"""]]