From 2807ab0a09cef9f7b07b23b2c639af6b3e14699f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 21 Jul 2023 16:04:11 -0400 Subject: [PATCH] gcrypt: Remove empty hash directories when dropping content As was recently done with the directory special remote. Note that the top directory passed to removeDirGeneric was changed to avoid deleting .git/annex or .git/annex/objects if they ended up empty. Sponsored-by: Brett Eisenberg on Patreon --- CHANGELOG | 2 +- Remote/GCrypt.hs | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ccc4f510ea..b9792a7de8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -22,7 +22,7 @@ git-annex (10.20230627) UNRELEASED; urgency=medium * S3: Allow setting publicurl=yes without public=yes, to support buckets that are configured with a Bucket Policy that allows public access. - * directory: Remove empty hash directories when dropping content. + * directory, gcrypt: Remove empty hash directories when dropping content. * dropunused: Support --jobs -- Joey Hess Mon, 26 Jun 2023 13:10:40 -0400 diff --git a/Remote/GCrypt.hs b/Remote/GCrypt.hs index fec30195c9..61e8b7210e 100644 --- a/Remote/GCrypt.hs +++ b/Remote/GCrypt.hs @@ -439,8 +439,8 @@ remove r rsyncopts accessmethod k = do remove' :: Git.Repo -> Remote -> Remote.Rsync.RsyncOpts -> AccessMethod -> Remover remove' repo r rsyncopts accessmethod k | not $ Git.repoIsUrl repo = guardUsable repo (giveup "cannot access remote") $ - liftIO $ Remote.Directory.removeDirGeneric False - (fromRawFilePath (Git.repoPath repo)) + liftIO $ Remote.Directory.removeDirGeneric True + (gCryptTopDir repo) (fromRawFilePath (parentDir (toRawFilePath (gCryptLocation repo k)))) | Git.repoIsSsh repo = shellOrRsync r removeshell removersync | accessmethod == AccessRsyncOverSsh = removersync @@ -466,10 +466,13 @@ checkKey' repo r rsyncopts accessmethod k checkrsync = Remote.Rsync.checkKey rsyncopts k checkshell = Ssh.inAnnex repo k +gCryptTopDir :: Git.Repo -> FilePath +gCryptTopDir repo = Git.repoLocation repo fromRawFilePath objectDir + {- Annexed objects are hashed using lower-case directories for max - portability. -} gCryptLocation :: Git.Repo -> Key -> FilePath -gCryptLocation repo key = Git.repoLocation repo fromRawFilePath objectDir +gCryptLocation repo key = gCryptTopDir repo fromRawFilePath (keyPath key (hashDirLower def)) data AccessMethod = AccessRsyncOverSsh | AccessGitAnnexShell -- 2.30.2