export --json: Fill in the file field
Like import was using ActionItemWorkTreeFile, it's ok to use it for export, even though it might not correspond with a file in the work tree. And renamed it to ActionItemTreeFile to make that clearer. Note that when an export has to rename files, it still uses ActionItemOther, so file will still be null in that case, but as no file is being transferred, that seems ok.
This commit is contained in:
parent
f87c63d998
commit
6481991208
10 changed files with 37 additions and 22 deletions
|
@ -3,6 +3,7 @@ git-annex (8.20210311) UNRELEASED; urgency=medium
|
|||
* export: When a submodule is in the tree to be exported, skip it.
|
||||
* import: When the previously exported tree contained a submodule,
|
||||
preserve it in the imported tree so it does not get deleted.
|
||||
* export --json: Fill in the file field.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Fri, 12 Mar 2021 12:06:37 -0400
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ seek o = startConcurrency commandStages $ do
|
|||
{- Pass file off to git-add. -}
|
||||
startSmall :: AddOptions -> SeekInput -> RawFilePath -> CommandStart
|
||||
startSmall o si file =
|
||||
starting "add" (ActionItemWorkTreeFile file) si $
|
||||
starting "add" (ActionItemTreeFile file) si $
|
||||
next $ addSmall (checkGitIgnoreOption o) file
|
||||
|
||||
addSmall :: CheckGitIgnore -> RawFilePath -> Annex Bool
|
||||
|
@ -120,7 +120,7 @@ addSmall ci file = do
|
|||
|
||||
startSmallOverridden :: AddOptions -> SeekInput -> RawFilePath -> CommandStart
|
||||
startSmallOverridden o si file =
|
||||
starting "add" (ActionItemWorkTreeFile file) si $ next $ do
|
||||
starting "add" (ActionItemTreeFile file) si $ next $ do
|
||||
showNote "adding content to git repository"
|
||||
addFile Small (checkGitIgnoreOption o) file
|
||||
|
||||
|
@ -148,7 +148,7 @@ start o si file addunlockedmatcher = do
|
|||
Just s
|
||||
| not (isRegularFile s) && not (isSymbolicLink s) -> stop
|
||||
| otherwise ->
|
||||
starting "add" (ActionItemWorkTreeFile file) si $
|
||||
starting "add" (ActionItemTreeFile file) si $
|
||||
if isSymbolicLink s
|
||||
then next $ addFile Small (checkGitIgnoreOption o) file
|
||||
else perform o file addunlockedmatcher
|
||||
|
@ -157,13 +157,13 @@ start o si file addunlockedmatcher = do
|
|||
Just s | isSymbolicLink s -> fixuplink key
|
||||
_ -> add
|
||||
fixuplink key =
|
||||
starting "add" (ActionItemWorkTreeFile file) si $
|
||||
starting "add" (ActionItemTreeFile file) si $
|
||||
addingExistingLink file key $ do
|
||||
liftIO $ removeFile (fromRawFilePath file)
|
||||
addLink (checkGitIgnoreOption o) file key Nothing
|
||||
next $ cleanup key =<< inAnnex key
|
||||
fixuppointer key =
|
||||
starting "add" (ActionItemWorkTreeFile file) si $
|
||||
starting "add" (ActionItemTreeFile file) si $
|
||||
addingExistingLink file key $ do
|
||||
Database.Keys.addAssociatedFile key =<< inRepo (toTopFilePath file)
|
||||
next $ addFile Large (checkGitIgnoreOption o) file
|
||||
|
|
|
@ -270,7 +270,7 @@ startExport r db cvar allfilledvar ti = do
|
|||
loc = mkExportLocation f
|
||||
f = getTopFilePath (Git.LsTree.file ti)
|
||||
af = AssociatedFile (Just f)
|
||||
ai = ActionItemOther (Just (fromRawFilePath f))
|
||||
ai = ActionItemTreeFile f
|
||||
si = SeekInput []
|
||||
notrecordedpresent ek = (||)
|
||||
<$> liftIO (notElem loc <$> getExportedLocation db ek)
|
||||
|
@ -332,7 +332,7 @@ startUnexport r db f shas = do
|
|||
where
|
||||
loc = mkExportLocation f'
|
||||
f' = getTopFilePath f
|
||||
ai = ActionItemOther (Just (fromRawFilePath f'))
|
||||
ai = ActionItemTreeFile f'
|
||||
si = SeekInput []
|
||||
|
||||
startUnexport' :: Remote -> ExportHandle -> TopFilePath -> Key -> CommandStart
|
||||
|
@ -342,7 +342,7 @@ startUnexport' r db f ek =
|
|||
where
|
||||
loc = mkExportLocation f'
|
||||
f' = getTopFilePath f
|
||||
ai = ActionItemOther (Just (fromRawFilePath f'))
|
||||
ai = ActionItemTreeFile f'
|
||||
si = SeekInput []
|
||||
|
||||
-- Unlike a usual drop from a repository, this does not check that
|
||||
|
@ -384,7 +384,7 @@ startRecoverIncomplete r db sha oldf
|
|||
| otherwise = do
|
||||
ek <- exportKey sha
|
||||
let loc = exportTempName ek
|
||||
let ai = ActionItemOther (Just (fromRawFilePath (fromExportLocation loc)))
|
||||
let ai = ActionItemTreeFile (fromExportLocation loc)
|
||||
let si = SeekInput []
|
||||
starting ("unexport " ++ name r) ai si $ do
|
||||
liftIO $ removeExportedLocation db ek oldloc
|
||||
|
|
|
@ -145,7 +145,7 @@ startLocal o addunlockedmatcher largematcher mode (srcfile, destfile) =
|
|||
, stop
|
||||
)
|
||||
where
|
||||
ai = ActionItemWorkTreeFile destfile
|
||||
ai = ActionItemTreeFile destfile
|
||||
si = SeekInput []
|
||||
|
||||
deletedup k = do
|
||||
|
|
|
@ -69,7 +69,7 @@ start si (file, newkey) = ifAnnexed file go stop
|
|||
| otherwise = starting "rekey" ai si $
|
||||
perform file oldkey newkey
|
||||
|
||||
ai = ActionItemWorkTreeFile file
|
||||
ai = ActionItemTreeFile file
|
||||
|
||||
perform :: RawFilePath -> Key -> Key -> CommandPerform
|
||||
perform file oldkey newkey = do
|
||||
|
|
|
@ -96,7 +96,7 @@ perform o remotemap key ai = do
|
|||
mapM_ (showRemoteUrls remotemap) urls
|
||||
Just formatter -> liftIO $ do
|
||||
let vs = Command.Find.formatVars key
|
||||
(AssociatedFile (actionItemWorkTreeFile ai))
|
||||
(AssociatedFile (actionItemFile ai))
|
||||
let showformatted muuid murl = putStr $
|
||||
Utility.Format.format formatter $
|
||||
M.fromList $ vs ++ catMaybes
|
||||
|
|
|
@ -83,7 +83,7 @@ showStartKey :: String -> Key -> ActionItem -> SeekInput -> Annex ()
|
|||
showStartKey command key ai si = outputMessage json $
|
||||
encodeBS' command <> " " <> actionItemDesc ai <> " "
|
||||
where
|
||||
json = JSON.start command (actionItemWorkTreeFile ai) (Just key) si
|
||||
json = JSON.start command (actionItemFile ai) (Just key) si
|
||||
|
||||
showStartOther :: String -> Maybe String -> SeekInput -> Annex ()
|
||||
showStartOther command mdesc si = outputMessage json $ encodeBS' $
|
||||
|
@ -97,7 +97,7 @@ showStartMessage (StartMessage command ai si) = case ai of
|
|||
ActionItemKey k -> showStartKey command k ai si
|
||||
ActionItemBranchFilePath _ k -> showStartKey command k ai si
|
||||
ActionItemFailedTransfer t _ -> showStartKey command (transferKey t) ai si
|
||||
ActionItemWorkTreeFile file -> showStart command file si
|
||||
ActionItemTreeFile file -> showStart command file si
|
||||
ActionItemOther msg -> showStartOther command msg si
|
||||
OnlyActionOn _ ai' -> showStartMessage (StartMessage command ai' si)
|
||||
showStartMessage (StartUsualMessages command ai si) = do
|
||||
|
|
|
@ -22,7 +22,7 @@ data ActionItem
|
|||
| ActionItemKey Key
|
||||
| ActionItemBranchFilePath BranchFilePath Key
|
||||
| ActionItemFailedTransfer Transfer TransferInfo
|
||||
| ActionItemWorkTreeFile RawFilePath
|
||||
| ActionItemTreeFile RawFilePath
|
||||
| ActionItemOther (Maybe String)
|
||||
-- Use to avoid more than one thread concurrently processing the
|
||||
-- same Key.
|
||||
|
@ -64,7 +64,7 @@ actionItemDesc (ActionItemKey k) = serializeKey' k
|
|||
actionItemDesc (ActionItemBranchFilePath bfp _) = descBranchFilePath bfp
|
||||
actionItemDesc (ActionItemFailedTransfer t i) = actionItemDesc $
|
||||
ActionItemAssociatedFile (associatedFile i) (transferKey t)
|
||||
actionItemDesc (ActionItemWorkTreeFile f) = f
|
||||
actionItemDesc (ActionItemTreeFile f) = f
|
||||
actionItemDesc (ActionItemOther s) = encodeBS' (fromMaybe "" s)
|
||||
actionItemDesc (OnlyActionOn _ ai) = actionItemDesc ai
|
||||
|
||||
|
@ -73,15 +73,15 @@ actionItemKey (ActionItemAssociatedFile _ k) = Just k
|
|||
actionItemKey (ActionItemKey k) = Just k
|
||||
actionItemKey (ActionItemBranchFilePath _ k) = Just k
|
||||
actionItemKey (ActionItemFailedTransfer t _) = Just (transferKey t)
|
||||
actionItemKey (ActionItemWorkTreeFile _) = Nothing
|
||||
actionItemKey (ActionItemTreeFile _) = Nothing
|
||||
actionItemKey (ActionItemOther _) = Nothing
|
||||
actionItemKey (OnlyActionOn _ ai) = actionItemKey ai
|
||||
|
||||
actionItemWorkTreeFile :: ActionItem -> Maybe RawFilePath
|
||||
actionItemWorkTreeFile (ActionItemAssociatedFile (AssociatedFile af) _) = af
|
||||
actionItemWorkTreeFile (ActionItemWorkTreeFile f) = Just f
|
||||
actionItemWorkTreeFile (OnlyActionOn _ ai) = actionItemWorkTreeFile ai
|
||||
actionItemWorkTreeFile _ = Nothing
|
||||
actionItemFile :: ActionItem -> Maybe RawFilePath
|
||||
actionItemFile (ActionItemAssociatedFile (AssociatedFile af) _) = af
|
||||
actionItemFile (ActionItemTreeFile f) = Just f
|
||||
actionItemFile (OnlyActionOn _ ai) = actionItemFile ai
|
||||
actionItemFile _ = Nothing
|
||||
|
||||
actionItemTransferDirection :: ActionItem -> Maybe Direction
|
||||
actionItemTransferDirection (ActionItemFailedTransfer t _) = Just $
|
||||
|
|
|
@ -22,3 +22,5 @@ This behavior was observed using the 4shared service, but I believe git-annex kn
|
|||
Thx!
|
||||
|
||||
[[!tag projects/datalad]]
|
||||
|
||||
> [[fixed|done]] --[[Joey]]
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
[[!comment format=mdwn
|
||||
username="joey"
|
||||
subject="""comment 1"""
|
||||
date="2021-03-12T18:09:48Z"
|
||||
content="""
|
||||
I've fixed this.
|
||||
|
||||
However, there is still a case where the file field is null, which is when
|
||||
an already exported file is renamed. Since nothing is transferred in that
|
||||
case, and 2 files are involved which doesn't fit the one file in the json,
|
||||
I left it as-is.
|
||||
"""]]
|
Loading…
Reference in a new issue