Skip to content

Commit b60115f

Browse files
committed
cmd-diff: move gc; conditionalize diff code
In the case of `cosa diff --gc` there will be no active differs so let's just move the gc code earlier and conditionalize on active_differs being non-empty for the rest of it.
1 parent fe44cd3 commit b60115f

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/cmd-diff

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -162,27 +162,27 @@ def main():
162162
diff_from = DiffBuildTarget.from_build(builds, args.diff_from, args.arch)
163163
diff_to = DiffBuildTarget.from_build(builds, args.diff_to, args.arch)
164164

165+
if args.gc:
166+
# some of the dirs in the rootfs are dumb and have "private" bits
167+
runcmd(['find', DIFF_CACHE, '-type', 'd', '-exec', 'chmod', 'u+rwx', '{}', '+'])
168+
shutil.rmtree(DIFF_CACHE)
169+
165170
# get activated differs
166171
active_differs = []
167172
for differ in DIFFERS:
168173
if getattr(args, differ.name.replace('-', '_')):
169174
active_differs += [differ]
170175

171-
# ensure commits are imported if we know we'll need them
172-
ostree_import = max([d.needs_ostree for d in active_differs])
173-
if ostree_import > OSTreeImport.NO:
174-
for target in [diff_from, diff_to]:
175-
import_ostree_commit('.', target.dir, target.meta, extract_json=False,
176-
partial_import=(ostree_import == OSTreeImport.PARTIAL))
177-
178-
# start diff'ing
179-
for differ in active_differs:
180-
differ.function(diff_from, diff_to)
181-
182-
if args.gc:
183-
# some of the dirs in the rootfs are dumb and have "private" bits
184-
runcmd(['find', DIFF_CACHE, '-type', 'd', '-exec', 'chmod', 'u+rwx', '{}', '+'])
185-
shutil.rmtree(DIFF_CACHE)
176+
if active_differs:
177+
# ensure commits are imported if we know we'll need them
178+
ostree_import = max([d.needs_ostree for d in active_differs])
179+
if ostree_import > OSTreeImport.NO:
180+
for target in [diff_from, diff_to]:
181+
import_ostree_commit('.', target.dir, target.meta, extract_json=False,
182+
partial_import=(ostree_import == OSTreeImport.PARTIAL))
183+
# start diff'ing
184+
for differ in active_differs:
185+
differ.function(diff_from, diff_to)
186186

187187

188188
def parse_args():

0 commit comments

Comments
 (0)