migrate: Fix --remove-size to work when a file is not present
authorJoey Hess <joeyh@joeyh.name>
Tue, 1 Apr 2025 14:47:31 +0000 (10:47 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 1 Apr 2025 14:47:31 +0000 (10:47 -0400)
5f74a45861357be2a3233ddbbdbe7f7b0cf1814e added this bug

CHANGELOG
Command/Migrate.hs
doc/bugs/migrate_--remove-size_does_nothing.mdwn
doc/bugs/migrate_--remove-size_does_nothing/comment_1_57e0c4a6b4183a9e08894a7c25b2efda._comment [new file with mode: 0644]

index 44a0305bd34510112229c064205e5ffc2ea06fc7..aa6dc06ea82a886996fe21b9db23626865526974 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,8 @@ git-annex (10.20250321) UNRELEASED; urgency=medium
   * httpalso: Windows url fix.
   * Added remote.name.annex-web-options config, which is a per-remote
     version of the annex.web-options config.
+  * migrate: Fix --remove-size to work when a file is not present.
+    Fixes reversion introduced in version 10.20231129.
 
  -- Joey Hess <id@joeyh.name>  Fri, 21 Mar 2025 12:27:11 -0400
 
index a2dab7ab0068b0512eaddb4257726cc1b1a2f209..ffaabf7da6677bcccb296a8ffd9a5659ed822a5a 100644 (file)
@@ -90,7 +90,7 @@ start o ksha si file key = do
                        newbackend <- chooseBackend file
                        if (newbackend /= oldbackend || upgradableKey oldbackend || forced) && exists
                                then go False oldbackend newbackend
-                               else if cantweaksize newbackend oldbackend && exists
+                               else if cantweaksize newbackend oldbackend exists
                                        then go True oldbackend newbackend
                                        else stop
   where
@@ -101,10 +101,10 @@ start o ksha si file key = do
                starting "migrate" (mkActionItem (key, file)) si $
                        perform onlytweaksize o file key keyrec oldbackend newbackend
 
-       cantweaksize newbackend oldbackend
+       cantweaksize newbackend oldbackend exists
                | removeSize o = isJust (fromKey keySize key)
                | newbackend /= oldbackend = False
-               | isNothing (fromKey keySize key) = True
+               | isNothing (fromKey keySize key) && exists = True
                | otherwise = False
 
        upgradableKey oldbackend = maybe False (\a -> a key) (canUpgradeKey oldbackend)
index 37d8582e343b29281bb7d2b6a97158fb481e5151..8e8861dc55b12e3690b6dbf0903a5f888e6cf070 100644 (file)
@@ -92,4 +92,4 @@ git-annex version: 10.20250115
 
 
 
-
+> [[fixed|done]] --[[Joey]]
diff --git a/doc/bugs/migrate_--remove-size_does_nothing/comment_1_57e0c4a6b4183a9e08894a7c25b2efda._comment b/doc/bugs/migrate_--remove-size_does_nothing/comment_1_57e0c4a6b4183a9e08894a7c25b2efda._comment
new file mode 100644 (file)
index 0000000..5e62a0d
--- /dev/null
@@ -0,0 +1,10 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 1"""
+ date="2025-04-01T14:39:24Z"
+ content="""
+I diagnose a bug introduced in 
+[[!commit 86dbe9a825b9c615c63e0cfc5e4a737a249f8989]]
+that makes it only be able to remove the size if the object file is locally
+present. Fixed.
+"""]]