From 92dfde25409ae2268ab2251920ed11646c122870 Mon Sep 17 00:00:00 2001
From: Reiko Asakura <asakurareiko@protonmail.ch>
Date: Tue, 26 Oct 2021 15:46:38 -0400
Subject: [PATCH] Call freezeContent after move into annex

This change better supports Windows ACL management using
annex.freezecontent-command and annex.thawcontent-command and matches
the behaviour of adding an unlocked file.

By calling freezeContent after the file has moved into the annex,
the file's delete permission can be denied. If the file's delete
permission is denied before moving into the annex, the file cannot
be moved or deleted. If the file's delete permission is not denied after
moving into the annex, it will likely inherit a grant for the delete
permission which allows it to be deleted irrespective of the permissions
of the parent directory.
---
 Annex/Content.hs | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Annex/Content.hs b/Annex/Content.hs
index da65143ab..89c36e612 100644
--- a/Annex/Content.hs
+++ b/Annex/Content.hs
@@ -346,6 +346,9 @@ moveAnnex key af src = ifM (checkSecureHashes' key)
            liftIO $ moveFile
                (fromRawFilePath src)
                (fromRawFilePath dest)
+           -- On Windows the delete permission must be denied only
+           -- after the content has been moved in the annex.
+           freezeContent dest
            g <- Annex.gitRepo 
            fs <- map (`fromTopFilePath` g)
                <$> Database.Keys.getAssociatedFiles key
-- 
2.30.2

applied --Joey