[unpackfs] Use callback instead of building giant string in memory
SEE #1740 By processing each line in turn (and just counting is) rather than collecting all of the lines of output from the tools, we end up with lower memory usage.
This commit is contained in:
parent
e8209089c6
commit
94039c19bb
@ -79,24 +79,24 @@ class UnpackEntry:
|
|||||||
"""
|
"""
|
||||||
Counts the number of files this entry has.
|
Counts the number of files this entry has.
|
||||||
"""
|
"""
|
||||||
fslist = ""
|
# Need a name we can use like a global
|
||||||
|
class counter(object):
|
||||||
|
count = 0
|
||||||
|
def cb_count(s):
|
||||||
|
counter.count += 1
|
||||||
|
|
||||||
if self.sourcefs == "squashfs":
|
if self.sourcefs == "squashfs":
|
||||||
fslist = subprocess.check_output(
|
libcalamares.utils.host_env_process_output(["unsquashfs", "-l", self.source], cb_count)
|
||||||
["unsquashfs", "-l", self.source]
|
|
||||||
)
|
|
||||||
|
|
||||||
elif self.sourcefs == "ext4":
|
elif self.sourcefs == "ext4":
|
||||||
fslist = subprocess.check_output(
|
libcalamares.utils.host_env_process_output(["find", self.mountPoint, "-type", "f"], cb_count)
|
||||||
["find", self.mountPoint, "-type", "f"]
|
|
||||||
)
|
|
||||||
|
|
||||||
elif self.is_file():
|
elif self.is_file():
|
||||||
# Hasn't been mounted, copy directly; find handles both
|
# Hasn't been mounted, copy directly; find handles both
|
||||||
# files and directories.
|
# files and directories.
|
||||||
fslist = subprocess.check_output(["find", self.source, "-type", "f"])
|
libcalamares.utils.host_env_process_output(["find", self.source, "-type", "f"], cb_count)
|
||||||
|
|
||||||
self.total = len(fslist.splitlines())
|
self.total = counter.count
|
||||||
return self.total
|
return self.total
|
||||||
|
|
||||||
def do_mount(self, base):
|
def do_mount(self, base):
|
||||||
|
Loading…
Reference in New Issue
Block a user