summaryrefslogtreecommitdiff
path: root/Logs/NumCopies.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2022-03-28 15:19:52 -0400
committerJoey Hess <joeyh@joeyh.name>2022-03-28 15:20:34 -0400
commitd266a41f8d191d3b3322ed5a6bb85bb8d2f53166 (patch)
tree2c23d22fea11efde5b850491f99ace84b4bc245c /Logs/NumCopies.hs
parentfdcb14d475f2b4e5735bcc3016fa4fe83dfb1ef4 (diff)
prevent numcopies or mincopies being configured to 0
Ignore annex.numcopies set to 0 in gitattributes or git config, or by git-annex numcopies or by --numcopies, since that configuration would make git-annex easily lose data. Same for mincopies. This is a continuation of the work to make data only be able to be lost when --force is used. It earlier led to the --trust option being disabled, and similar reasoning applies here. Most numcopies configs had docs that strongly discouraged setting it to 0 anyway. And I can't imagine a use case for setting to 0. Not that there might not be one, but it's just so far from the intended use case of git-annex, of managing and storing your data, that it does not seem like it makes sense to cater to such a hypothetical use case, where any git-annex drop can lose your data at any time. Using a smart constructor makes sure every place avoids 0. Note that this does mean that NumCopies is for the configured desired values, and not the actual existing number of copies, which of course can be 0. The name configuredNumCopies is used to make that clear. Sponsored-by: Brock Spratlen on Patreon
Diffstat (limited to 'Logs/NumCopies.hs')
-rw-r--r--Logs/NumCopies.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/Logs/NumCopies.hs b/Logs/NumCopies.hs
index 19a1fe9c72..3c358819bb 100644
--- a/Logs/NumCopies.hs
+++ b/Logs/NumCopies.hs
@@ -24,12 +24,12 @@ import Logs
import Logs.SingleValue
instance SingleValueSerializable NumCopies where
- serialize (NumCopies n) = encodeBS (show n)
- deserialize = NumCopies <$$> readish . decodeBS
+ serialize = encodeBS . show . fromNumCopies
+ deserialize = configuredNumCopies <$$> readish . decodeBS
instance SingleValueSerializable MinCopies where
- serialize (MinCopies n) = encodeBS (show n)
- deserialize = MinCopies <$$> readish . decodeBS
+ serialize = encodeBS . show . fromMinCopies
+ deserialize = configuredMinCopies <$$> readish . decodeBS
setGlobalNumCopies :: NumCopies -> Annex ()
setGlobalNumCopies new = do