Skip to content

Commit f6e8bea

Browse files
authored
Merge pull request #999 from tleedjarv/fix-paths-proplist-error
Make archive format compatible with <= 2.53.3
2 parents 39dad2f + 01298ed commit f6e8bea

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

src/update.ml

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,13 @@ let verboseArchiveName thisRoot =
420420
Printf.sprintf "Archive for root %s synchronizing roots %s"
421421
thisRoot (Prefs.read rootsName)
422422

423+
module PathMap = MyMap.Make (Path)
424+
425+
let mpaths = PathMap.m Proplist.m
426+
427+
let propPathKey : Proplist.t PathMap.t Proplist.key =
428+
Proplist.register "paths" mpaths
429+
423430
let mpayload = Umarshal.prod4
424431
marchive Umarshal.int Umarshal.string Proplist.m
425432
Umarshal.id Umarshal.id
@@ -486,6 +493,14 @@ let loadArchiveLocal fspath (thisRoot: string) :
486493
(* Load the datastructure *)
487494
let ((archive, hash, magic, properties) : archive * int * string * Proplist.t) =
488495
Umarshal.from_channel mpayload c in
496+
(* "paths" is stored separately to keep the archive file readable
497+
for versions <= 2.53.3 *)
498+
let properties =
499+
try
500+
let paths = Umarshal.from_channel mpaths c in
501+
Proplist.add propPathKey paths properties
502+
with End_of_file -> properties
503+
in
489504
close_in c;
490505
(* Restore to the negotiated features *)
491506
let () = Features.setEnabled negotiatedFts in
@@ -587,7 +602,14 @@ let storeArchiveLocal fspath thisRoot archive hash magic properties =
587602
output_string c "\030";
588603
output_string c (String.concat "\030" (Features.changingArchiveFormat ()));
589604
output_string c "\n";
605+
(* "paths" is stored separately to keep the archive file readable
606+
for versions <= 2.53.3. Otherwise the older versions would fail
607+
with a fatal error "Property lists: paths not yet registered!" *)
608+
let paths =
609+
try Proplist.find propPathKey properties with Not_found -> PathMap.empty in
610+
let properties = Proplist.remove propPathKey properties in
590611
Umarshal.to_channel mpayload c (archive, hash, magic, properties);
612+
if not (PathMap.is_empty paths) then Umarshal.to_channel mpaths c paths;
591613
close_out c))
592614

593615
(* IMPORTANT! This val is here for smoother upgrades from versions <= 2.51.5
@@ -2370,11 +2392,6 @@ let mustRescanProps props setProps =
23702392
newXattrs = Some true || newACL = Some true
23712393
end
23722394

2373-
module PathMap = MyMap.Make (Path)
2374-
2375-
let propPathKey : Proplist.t PathMap.t Proplist.key =
2376-
Proplist.register "paths" (PathMap.m Proplist.m)
2377-
23782395
let getArchivePropsForPath thisRoot path =
23792396
let props = getArchiveProps thisRoot in
23802397
try
@@ -2457,8 +2474,20 @@ let extractOldStyleProps props =
24572474

24582475
let checkNoUpdatePredicateChange thisRoot paths =
24592476
(* Default to old style (<= 2.53.3) and then the new style, per path *)
2460-
let oldprops = getArchiveProps thisRoot in
2461-
setArchivePropsLocal thisRoot (clearOldStyleProps oldprops);
2477+
let hasNewPropPaths =
2478+
try
2479+
ignore (Proplist.find propPathKey (getArchiveProps thisRoot));
2480+
true
2481+
with Not_found -> false
2482+
in
2483+
let oldprops =
2484+
if hasNewPropPaths then Proplist.empty else getArchiveProps thisRoot in
2485+
(* FIXME: Enable in some future version: setArchivePropsLocal thisRoot (clearOldStyleProps oldprops); *)
2486+
(* FIXME: Remove in some future version.
2487+
Store global paths props for versions <= 2.53.3. Only for compatibility. *)
2488+
ignore (mustRescanProps (getArchiveProps thisRoot) (setArchivePropsLocal thisRoot));
2489+
ignore (updatePredicateChanged (getArchiveProps thisRoot) (setArchivePropsLocal thisRoot));
2490+
(* FIXME: ^ Remove the above in some future version ^ *)
24622491
let getPropsForPath path =
24632492
let pprops = getArchivePropsForPath thisRoot path in
24642493
if pprops <> Proplist.empty then pprops

0 commit comments

Comments
 (0)