cleanup
This commit is contained in:
parent
f66f97c90e
commit
33e18d3d02
2 changed files with 5 additions and 13 deletions
|
@ -23,8 +23,6 @@ command = [Command "drop" paramPaths defaultChecks seek
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
seek = [withNumCopies start]
|
seek = [withNumCopies start]
|
||||||
|
|
||||||
{- Indicates a file's content is not wanted anymore, and should be removed
|
|
||||||
- if it's safe to do so. -}
|
|
||||||
start :: FilePath -> Maybe Int -> CommandStart
|
start :: FilePath -> Maybe Int -> CommandStart
|
||||||
start file numcopies = isAnnexed file $ \(key, _) -> do
|
start file numcopies = isAnnexed file $ \(key, _) -> do
|
||||||
present <- inAnnex key
|
present <- inAnnex key
|
||||||
|
@ -36,7 +34,7 @@ start file numcopies = isAnnexed file $ \(key, _) -> do
|
||||||
|
|
||||||
perform :: Key -> Maybe Int -> CommandPerform
|
perform :: Key -> Maybe Int -> CommandPerform
|
||||||
perform key numcopies = do
|
perform key numcopies = do
|
||||||
success <- dropKey key numcopies
|
success <- canDropKey key numcopies
|
||||||
if success
|
if success
|
||||||
then next $ cleanup key
|
then next $ cleanup key
|
||||||
else stop
|
else stop
|
||||||
|
@ -48,10 +46,9 @@ cleanup key = do
|
||||||
return True
|
return True
|
||||||
|
|
||||||
{- Checks remotes to verify that enough copies of a key exist to allow
|
{- Checks remotes to verify that enough copies of a key exist to allow
|
||||||
- for a key to be safely removed (with no data loss), and fails with an
|
- for a key to be safely removed (with no data loss). -}
|
||||||
- error if not. -}
|
canDropKey :: Key -> Maybe Int -> Annex Bool
|
||||||
dropKey :: Key -> Maybe Int -> Annex Bool
|
canDropKey key numcopiesM = do
|
||||||
dropKey key numcopiesM = do
|
|
||||||
force <- Annex.getState Annex.force
|
force <- Annex.getState Annex.force
|
||||||
if force || numcopiesM == Just 0
|
if force || numcopiesM == Just 0
|
||||||
then return True
|
then return True
|
||||||
|
|
|
@ -9,7 +9,6 @@ module Command.Unannex where
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import Command
|
import Command
|
||||||
import qualified Command.Drop
|
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
import qualified Annex.Queue
|
import qualified Annex.Queue
|
||||||
import Utility.FileMode
|
import Utility.FileMode
|
||||||
|
@ -44,11 +43,7 @@ start file = isAnnexed file $ \(key, _) -> do
|
||||||
else stop
|
else stop
|
||||||
|
|
||||||
perform :: FilePath -> Key -> CommandPerform
|
perform :: FilePath -> Key -> CommandPerform
|
||||||
perform file key = do
|
perform file key = next $ cleanup file key
|
||||||
ok <- Command.Drop.dropKey key (Just 0) -- always remove
|
|
||||||
if ok
|
|
||||||
then next $ cleanup file key
|
|
||||||
else stop
|
|
||||||
|
|
||||||
cleanup :: FilePath -> Key -> CommandCleanup
|
cleanup :: FilePath -> Key -> CommandCleanup
|
||||||
cleanup file key = do
|
cleanup file key = do
|
||||||
|
|
Loading…
Reference in a new issue