From: Joey Hess Date: Sun, 31 Mar 2013 23:00:43 +0000 (-0400) Subject: move content from remote when user asks to delete it X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~4694 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d888fb6a4b7bfd0335d52946e338c3b3b3f2f923;p=git-annex.git move content from remote when user asks to delete it --- diff --git a/Assistant/WebApp/Configurators/Delete.hs b/Assistant/WebApp/Configurators/Delete.hs index 925a58c6d9..877b0e3565 100644 --- a/Assistant/WebApp/Configurators/Delete.hs +++ b/Assistant/WebApp/Configurators/Delete.hs @@ -12,14 +12,16 @@ module Assistant.WebApp.Configurators.Delete where import Assistant.WebApp.Common import Assistant.WebApp.Utility import Assistant.DaemonStatus +import Assistant.ScanRemotes import qualified Remote -import qualified Types.Remote as Remote import Remote.List (remoteListRefresh) -import Command.Dead (markDead) import qualified Git.Command import qualified Git import Locations.UserConfig import Utility.FileMode +import Logs.Trust +import Logs.PreferredContent +import Types.StandardGroups import qualified Data.Text as T import System.IO.HVFS (SystemFS(..)) @@ -28,7 +30,7 @@ getDeleteRepositoryR :: UUID -> Handler RepHtml getDeleteRepositoryR uuid = go =<< liftAnnex (Remote.remoteFromUUID uuid) where go Nothing = redirect DeleteCurrentRepositoryR - go (Just r) = page "Delete repository" (Just Configuration) $ do + go (Just r) = deletionPage $ do reponame <- liftAnnex $ concat <$> Remote.prettyListUUIDs [uuid] $(widgetFile "configurators/delete/choose") @@ -51,24 +53,17 @@ removeRemote uuid = do updateSyncRemotes return remote -getDeleteRepositoryContentsR :: UUID -> Handler RepHtml -getDeleteRepositoryContentsR = deleteRepositoryContents - -postDeleteRepositoryContentsR :: UUID -> Handler RepHtml -postDeleteRepositoryContentsR = deleteRepositoryContents +getStartDeleteRepositoryContentsR :: UUID -> Handler RepHtml +getStartDeleteRepositoryContentsR uuid = deletionPage $ do + remote <- fromMaybe (error "unknown remote") + <$> liftAnnex (Remote.remoteFromUUID uuid) + liftAnnex $ do + trustSet uuid UnTrusted + setStandardGroup uuid UnwantedGroup + liftAssistant $ addScanRemotes True [remote] -deleteRepositoryContents :: UUID -> Handler RepHtml -deleteRepositoryContents uuid = dangerPage $ do reponame <- liftAnnex $ concat <$> Remote.prettyListUUIDs [uuid] - ((result, form), enctype) <- lift $ - runFormPost $ renderBootstrap $ sanityVerifierAForm $ - SanityVerifier magicphrase - case result of - FormSuccess _ -> do - liftAnnex $ markDead uuid - oldremote <- liftAssistant $ removeRemote uuid - $(widgetFile "configurators/delete/repositorycontents/nextstep") - _ -> $(widgetFile "configurators/delete/repositorycontents") + $(widgetFile "configurators/delete/started") getDeleteCurrentRepositoryR :: Handler RepHtml getDeleteCurrentRepositoryR = deleteCurrentRepository @@ -122,6 +117,9 @@ sanityVerifierAForm template = SanityVerifier insane = "Maybe this is not a good idea..." :: Text +deletionPage :: Widget -> Handler RepHtml +deletionPage = page "Delete repository" (Just Configuration) + dangerPage :: Widget -> Handler RepHtml dangerPage = page "Danger danger danger" (Just Configuration) diff --git a/Assistant/WebApp/routes b/Assistant/WebApp/routes index a83badc517..6d23f181d0 100644 --- a/Assistant/WebApp/routes +++ b/Assistant/WebApp/routes @@ -31,7 +31,7 @@ /config/repository/sync/enable/#UUID EnableSyncR GET /config/repository/delete/choose/#UUID DeleteRepositoryR GET /config/repository/delete/fromlist/#UUID DeleteRepositoryFromListR GET -/config/repository/delete/contents/#UUID DeleteRepositoryContentsR GET POST +/config/repository/delete/contents/start/#UUID StartDeleteRepositoryContentsR GET /config/repository/delete/here DeleteCurrentRepositoryR GET POST /config/repository/add/drive AddDriveR GET POST diff --git a/Types/StandardGroups.hs b/Types/StandardGroups.hs index 722136520c..2670ec2a43 100644 --- a/Types/StandardGroups.hs +++ b/Types/StandardGroups.hs @@ -51,26 +51,27 @@ descStandardGroup SmallArchiveGroup = "small archive: archives files located in descStandardGroup FullArchiveGroup = "full archive: archives all files not archived elsewhere" descStandardGroup SourceGroup = "file source: moves files on to other repositories" descStandardGroup ManualGroup = "manual mode: only stores files you manually choose" -descStandardGroup UnwantedGroup "unwanted: a repository in the process of being removed" +descStandardGroup UnwantedGroup = "unwanted: remove content from this repository" {- See doc/preferred_content.mdwn for explanations of these expressions. -} preferredContent :: StandardGroup -> String -preferredContent ClientGroup = normal +preferredContent ClientGroup = lastResort "exclude=*/archive/* and exclude=archive/*" -preferredContent TransferGroup = normal $ +preferredContent TransferGroup = lastResort $ "not (inallgroup=client and copies=client:2) and " ++ preferredContent ClientGroup preferredContent BackupGroup = "include=*" -preferredContent IncrementalBackupGroup = normal $ +preferredContent IncrementalBackupGroup = lastResort $ "include=* and (not copies=incrementalbackup:1)" -preferredContent SmallArchiveGroup = normal $ +preferredContent SmallArchiveGroup = lastResort $ "(include=*/archive/* or include=archive/*) and " ++ preferredContent FullArchiveGroup -preferredContent FullArchiveGroup = normal $ +preferredContent FullArchiveGroup = lastResort $ "not (copies=archive:1 or copies=smallarchive:1)" preferredContent SourceGroup = "not (copies=1)" -preferredContent ManualGroup = normal $ +preferredContent ManualGroup = lastResort $ "present and exclude=*/archive/* and exclude=archive/*" preferredContent UnwantedGroup = "exclude=*" - where - {- Most repositories want any content that is only on untrusted - - or dead repositories. -} - normal s = "(" ++ s ++ ") or (not copies=semitrusted:1)" + +{- Most repositories want any content that is only on untrusted + - or dead repositories. -} +lastResort :: String -> String +lastResort s = "(" ++ s ++ ") or (not copies=semitrusted:1)" diff --git a/debian/changelog b/debian/changelog index 5c2a44a4e8..8b32298713 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,8 +20,8 @@ git-annex (4.20130324) UNRELEASED; urgency=low Thanks, guilhem for the patch. * webapp: Added UI to delete repositories. Closes: #689847 * Adjust built-in preferred content expressions to make most types - of repositories want content that is only located on untrusted or dead - repositories. + of repositories want content that is only located on untrusted, dead, + and unwanted repositories. -- Joey Hess Mon, 25 Mar 2013 10:21:46 -0400 diff --git a/templates/configurators/delete/choose.hamlet b/templates/configurators/delete/choose.hamlet index d38cf2f6d5..3e0301da6a 100644 --- a/templates/configurators/delete/choose.hamlet +++ b/templates/configurators/delete/choose.hamlet @@ -10,12 +10,14 @@ but its contents left as-is. This prevents further syncing # to the repository. You can add the repository back at any time.
- + Remove repository from list

-or-

- All data in the repository can be deleted. This is dangerous! + All data in the repository can be moved off it, to other repositories. # + Once all the data has been transferred, the repository can be safely # + deleted.
-
- Remove repository and all its contents + + Start deletion process diff --git a/templates/configurators/delete/repositorycontents.hamlet b/templates/configurators/delete/repositorycontents.hamlet deleted file mode 100644 index 3f9a5a25b2..0000000000 --- a/templates/configurators/delete/repositorycontents.hamlet +++ /dev/null @@ -1,20 +0,0 @@ -

-

- Delete repository contents? -

- Deleting the contents of the repository "#{reponame}" could cause # - you to lose data. Some files might only be stored in # - that repository. -

- If you choose to delete the repository, and potentially lose # - data, enter "#{magicphrase}" into the box. -

-

-
- ^{form} - ^{webAppFormAuthToken} -
-