@@ -144,18 +144,23 @@ def addVolume(self, container, name, **kwargs):
144144 self .action ("quiet" , "apfs" , "addVolume" , container , "apfs" , name , * args , verbose = True )
145145
146146 def addPartition (self , after , fs , label , size ):
147+ size = str (size )
147148 self .action ("quiet" , "addPartition" , after , fs , label , size , verbose = True )
149+
148150 disk = after .rsplit ("s" , 1 )[0 ]
151+
149152 self .get_list ()
150- for i , p in enumerate (self .disk_parts [disk ]["Partitions" ]):
151- if after == p ["DeviceIdentifier" ]:
152- break
153- else :
154- raise Exception ("Could not find new partition" )
153+ parts = self .get_partitions (disk )
154+
155+ for i , part in enumerate (parts ):
156+ logging .info (f"Checking #{ i } { part .name } ..." )
157+ if part .name == after :
158+ logging .info (f"Found previous partition { part .name } ..." )
159+ new_part = self .get_partition_info (parts [i + 1 ].name , refresh_apfs = (fs == "apfs" ))
160+ logging .info (f"New partition: { new_part !r} " )
161+ return new_part
155162
156- new = self .disk_parts [disk ]["Partitions" ][i + 1 ]
157- return self .get_partition_info (new ["DeviceIdentifier" ],
158- refresh_apfs = (fs == "apfs" ))
163+ raise Exception ("Could not find new partition" )
159164
160165 def changeVolumeRole (self , volume , role ):
161166 self .action ("quiet" , "apfs" , "changeVolumeRole" , volume , role , verbose = True )
0 commit comments