Anonymous avatar Anonymous committed 3f7ad6b

convert atom bucket names in a pre-0.5 backup dump to binary bucket names during backup-restore

Comments (0)

Files changed (1)

src/riak_backup.erl

     {ok, r_table} = dets:open_file(r_table, [{file, Filename}]),
     {ok, Client} = riak:client_connect(IP,list_to_integer(PortStr),list_to_atom(Cookie)),
     Trav = dets:traverse(r_table,
-      fun({{Bucket,Key},V}) ->
-              RObj0 = binary_to_term(V),
+      fun({{Bucket0,Key},V}) ->
+              RObj00 = binary_to_term(V),
+              {Bucket, RObj0} =
+                  if is_binary(Bucket0) -> {Bucket0, RObj00};
+                     is_atom(Bucket0) ->
+                          BN = list_to_binary(atom_to_list(Bucket0)),
+                          {BN,
+                           riak_object:set_vclock(
+                             riak_object:set_contents(
+                               riak_object:new(BN, Key, backup_placeholder),
+                               riak_object:get_contents(RObj00)),
+                             riak_object:vclock(RObj00))}
+                  end,
               RObj = riak_object:update_metadata(RObj0,
                        dict:store("no_update",no_update,
                          riak_object:get_update_metadata(RObj0))),
     {ok, r_table} = dets:open_file(r_table, [{file, Filename}]),
     {ok, Client} = riak:local_client(),
     Trav = dets:traverse(r_table,
-      fun({{Bucket,Key},V}) ->
-              RObj0 = binary_to_term(V),
+      fun({{Bucket0,Key},V}) ->
+              RObj00 = binary_to_term(V),
+              {Bucket, RObj0} =
+                  if is_binary(Bucket0) -> {Bucket0, RObj00};
+                     is_atom(Bucket0) ->
+                          BN = list_to_binary(atom_to_list(Bucket0)),
+                          {BN,
+                           riak_object:set_vclock(
+                             riak_object:set_contents(
+                               riak_object:new(BN, Key, backup_placeholder),
+                               riak_object:get_contents(RObj00)),
+                             riak_object:vclock(RObj00))}
+                  end,
               MD0 = dict:store("no_update",no_update, 
                                riak_object:get_update_metadata(RObj0)),
               {ObjMD,_} = hd(riak_object:get_contents(RObj0)),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.