b0VIM 7.4 {S*w ejoeydarkstar~joey/src/git-annex/Assistant/WebApp/Configurators/Local.hsutf-8 3210#"! Utpocpcd6RadoMIHiF0 m R : (  x g O A .  x h A @    ~ ` C f B , &   ~@?n[-;== \Y - the user probably wants to put it there. Unless that directory - If run in another directory, that the user can write to, - - ~/Desktop/annex, when a Desktop directory exists, and ~/annex otherwise.{- On first run, if run in the home directory, default to putting it in expandTilde _ path = path expandTilde home ('~':'/':path) = home path runcheck (chk, msg) = ifM chk ( return $ Just msg, return Nothing ) where Just prob -> Left prob Nothing -> Right $ Just $ T.pack basepath case headMaybe problems of return $ ] , (not <$> canWrite path, "Cannot write a repository there.") , (not <$> doesDirectoryExist parent, "Parent directory does not exist.") , (return $ path == home, "Sorry, using git-annex for your whole home directory is not currently supported.") , (doesFileExist path, "A file already exists with that name.") , (return $ all isSpace basepath, "A blank path? Seems unlikely.") [ (return $ path == "/", "Enter the full path to use for the repository.") problems <- catMaybes <$> mapM runcheck let parent = parentDir path path <- absPath basepath let basepath = expandTilde home $ T.unpack p home <- myHomeDircheckRepositoryPath p = docheckRepositoryPath :: Text -> IO (Either (SomeMessage WebApp) (Maybe Text)) - expanded in the returned path. -}{- As well as checking the path for a lot of silly things, tilde is nopath = return $ Left "Enter a location for the repository" parse _ = nopath parse [] = return $ Right Nothing | otherwise = liftIO $ checkRepositoryPath path | T.null path = nopath parse [path] [whamlet||] view idAttr nameAttr attrs val isReq = where } , fieldView = view#endif , fieldEnctype = UrlEncoded { fieldParse = \l _ -> parse l#else { fieldParse = parse#if ! MIN_VERSION_yesod_form(1,2,0)repositoryPathField autofocus = Field#endifrepositoryPathField :: forall sub. Bool -> Field sub WebApp Text#elserepositoryPathField :: forall (m :: * -> *). (MonadIO m, HandlerSite m ~ WebApp) => Bool -> Field m Text#if MIN_VERSION_yesod(1,2,0) - to use as a repository. -} - Validates that the path entered is not empty, and is a safe value -{- Custom field display for a RepositoryPath, with an icon etc. deriving Showdata RepositoryPath = RepositoryPath Textimport qualified Text.Hamlet as Hamletimport Data.Ordimport Data.Charimport qualified Data.Map as Mimport qualified Data.Text as Timport qualified Types.Remoteimport qualified Remote.GCrypt as GCryptimport qualified Annex.Branchimport Utility.Gpgimport Configimport Utility.UserInfoimport Logs.UUIDimport Logs.PreferredContentimport Types.StandardGroupsimport Annex.Directimport Annex.UUIDimport Remote (prettyUUID)import Utility.DataUnits#endifimport Utility.Mounts#ifdef WITH_CLIBSimport Utility.DiskFreeimport Utility.FreeDesktopimport Config.Filesimport qualified Anneximport qualified Git.Commandimport qualified Git.Configimport qualified Git.Constructimport qualified Gitimport Annex.Initimport Assistant.Restartimport Assistant.Syncimport Assistant.WebApp.MakeRemoteimport Assistant.WebApp.Gpgimport Assistant.WebApp.Commonmodule Assistant.WebApp.Configurators.Local where{-# LANGUAGE CPP, QuasiQuotes, TemplateHaskell, OverloadedStrings, RankNTypes, KindSignatures, TypeFamilies #-} -} - Licensed under the GNU AGPL version 3 or higher. - - Copyright 2012 Joey Hess -{- git-annex assistant webapp configurators for making local repositoriesadVR|L<6 ^V! y 2   h X m R B "  { Y H - x o n H  kj:7lE_^VU return $ if u == NoUUID then Nothing else Just u u <- getUUIDprobeUUID dir = catchDefaultIO Nothing $ inDir dir $ doprobeUUID :: FilePath -> IO (Maybe UUID) - not be a git-annex repo. -}{- Gets the UUID of the git repo at a location, which may not exist, or catchDefaultIO Nothing (Git.Construct.checkForRepo dir)probeRepoExists dir = isJust <$>probeRepoExists :: FilePath -> IO Bool{- Checks if a git repo exists at a location. -} catchBoolIO $ fileAccess tocheck False True False (return dir, return $ parentDir dir) tocheck <- ifM (doesDirectoryExist dir)canWrite dir = docanWrite :: FilePath -> IO Bool - the parent directory is checked instead. -} - The directory may be in the process of being created; if so -{- Checks if the user can write to a directory. Annex.Branch.commit "update" - added. -} - available for merging when a removable drive repo is being {- Ensure branch gets committed right away so it is initialize descinitRepo' desc = unlessM isInitialized $ doinitRepo' :: Maybe String -> Annex () getUUID initRepo' descinitRepo False _ dir desc = inDir dir $ do{- Repo already exists, could be a non-git-annex repo though. -} getUUID [Param "config", Param "gc.auto", Param "0"] inRepo $ Git.Command.run setDirect True when primary_assistant_repo $ do -} - once a day. - Automatic gc is disabled, as it can be slow. Insted, gc is done - {- Repositories directly managed by the assistant use direct mode. ] , Param "created repository" , Param "-m" , Param "--allow-empty" , Param "--quiet" [ Param "commit" void $ inRepo $ Git.Command.runBool unlessM (Git.Config.isBare <$> gitRepo) $ - to have it will work, before any files are added. -} {- Initialize the master branch, so things that expect initRepo' descinitRepo True primary_assistant_repo dir desc = inDir dir $ doinitRepo :: Bool -> Bool -> FilePath -> Maybe String -> IO UUID{- Creates a new repository, and returns its UUID. -} Annex.eval state a state <- Annex.new =<< Git.Config.read =<< Git.Construct.fromPath dirinDir dir a = doinDir :: FilePath -> Annex a -> IO a{- Runs an action in the git repository in the specified directory. -} | otherwise = baseparams ++ [File path] | bare = baseparams ++ [Param "--bare", File path] params baseparams = [Param "init", Param "--quiet"] where ) return True error $ "git init failed!\nOutput:\n" ++ transcript unless ok $ processTranscript "git" (toCommand params) Nothing (transcript, ok) <- , do ( return FalsemakeRepo path bare = ifM (probeRepoExists path)makeRepo :: FilePath -> Bool -> IO Bool - exists, returns False. -}{- Makes a new git repository. Or, if a git repository already