Merge pull request #724 from mwhudson/partition-order

ensure partitions are emitted in order
This commit is contained in:
Michael Hudson-Doyle 2020-04-20 20:15:48 +12:00 committed by GitHub
commit 6990caadfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -1487,6 +1487,11 @@ class FilesystemModel(object):
next_work.append(part) next_work.append(part)
def can_emit(obj): def can_emit(obj):
if obj.type == "partition":
ensure_partitions(obj.device)
for p in obj.device.partitions():
if p._number < obj._number and p.id not in emitted_ids:
return False
for dep in dependencies(obj): for dep in dependencies(obj):
if dep.id not in emitted_ids: if dep.id not in emitted_ids:
if dep not in work and dep not in next_work: if dep not in work and dep not in next_work:

View File

@ -128,6 +128,7 @@ class PartitionViewTests(unittest.TestCase):
model, disk = make_model_and_disk() model, disk = make_model_and_disk()
partition = model.add_partition(disk, 512*(2**20)) partition = model.add_partition(disk, 512*(2**20))
partition.preserve = True partition.preserve = True
partition.number = 1
fs = model.add_filesystem(partition, "ext4") fs = model.add_filesystem(partition, "ext4")
model._orig_config = model._render_actions() model._orig_config = model._render_actions()
fs.preserve = True fs.preserve = True