don't bring forward old values in new log line
This commit is contained in:
parent
9f7e76130e
commit
4789d9910a
1 changed files with 14 additions and 15 deletions
|
@ -32,17 +32,16 @@ start (file:settings) = ifAnnexed file
|
||||||
start _ = error "specify a file and the metadata to set"
|
start _ = error "specify a file and the metadata to set"
|
||||||
|
|
||||||
perform :: Key -> [Action] -> CommandPerform
|
perform :: Key -> [Action] -> CommandPerform
|
||||||
perform k actions = do
|
perform k [] = next $ cleanup k
|
||||||
m <- getCurrentMetaData k
|
perform k as = do
|
||||||
if null actions
|
oldm <- getCurrentMetaData k
|
||||||
then next $ cleanup m
|
let m = foldr (apply oldm) newMetaData as
|
||||||
else do
|
addMetaData k m
|
||||||
let m' = foldr apply m actions
|
next $ cleanup k
|
||||||
addMetaData k m'
|
|
||||||
next $ cleanup m'
|
|
||||||
|
|
||||||
cleanup :: MetaData -> CommandCleanup
|
cleanup :: Key -> CommandCleanup
|
||||||
cleanup m = do
|
cleanup k = do
|
||||||
|
m <- getCurrentMetaData k
|
||||||
showLongNote $ unlines $ concatMap showmeta $ fromMetaData $ currentMetaData m
|
showLongNote $ unlines $ concatMap showmeta $ fromMetaData $ currentMetaData m
|
||||||
return True
|
return True
|
||||||
where
|
where
|
||||||
|
@ -65,9 +64,9 @@ parse p = case lastMaybe f of
|
||||||
mkf fld = fromMaybe (badfield fld) (toMetaField fld)
|
mkf fld = fromMaybe (badfield fld) (toMetaField fld)
|
||||||
badfield fld = error $ "Illegal metadata field name, \"" ++ fld ++ "\""
|
badfield fld = error $ "Illegal metadata field name, \"" ++ fld ++ "\""
|
||||||
|
|
||||||
apply :: Action -> MetaData -> MetaData
|
apply :: MetaData -> Action -> MetaData -> MetaData
|
||||||
apply (AddMeta f v) m = updateMetaData f v m
|
apply _ (AddMeta f v) m = updateMetaData f v m
|
||||||
apply (DelMeta f oldv) m = updateMetaData f (unsetMetaValue oldv) m
|
apply _ (DelMeta f oldv) m = updateMetaData f (unsetMetaValue oldv) m
|
||||||
apply (SetMeta f v) m = updateMetaData f v $
|
apply oldm (SetMeta f v) m = updateMetaData f v $
|
||||||
foldr (updateMetaData f) m $
|
foldr (updateMetaData f) m $
|
||||||
map unsetMetaValue $ S.toList $ currentMetaDataValues f m
|
map unsetMetaValue $ S.toList $ currentMetaDataValues f oldm
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue