[unpackfs] Give entries a weight
When there are multiple entries, the overall weight of the module is divided between the entries: currently each entry takes an equal amount of space in the overall progress. When there are multiple entries which take wildly different amounts of time (e.g. a squash-fs and a single file) then the progress overall looks weird: the squash-fs gets half of this module's weight, and the single file does too. With the new *weight* key for entries, that division can be tweaked so that progress looks more "even".
This commit is contained in:
parent
44f8a7ae47
commit
632445a431
@ -48,8 +48,8 @@ class UnpackEntry:
|
|||||||
:param sourcefs:
|
:param sourcefs:
|
||||||
:param destination:
|
:param destination:
|
||||||
"""
|
"""
|
||||||
__slots__ = ['source', 'sourcefs', 'destination', 'copied', 'total', 'exclude', 'excludeFile',
|
__slots__ = ('source', 'sourcefs', 'destination', 'copied', 'total', 'exclude', 'excludeFile',
|
||||||
'mountPoint']
|
'mountPoint', 'weight', 'accumulated_weight')
|
||||||
|
|
||||||
def __init__(self, source, sourcefs, destination):
|
def __init__(self, source, sourcefs, destination):
|
||||||
"""
|
"""
|
||||||
@ -71,6 +71,8 @@ class UnpackEntry:
|
|||||||
self.copied = 0
|
self.copied = 0
|
||||||
self.total = 0
|
self.total = 0
|
||||||
self.mountPoint = None
|
self.mountPoint = None
|
||||||
|
self.weight = 1
|
||||||
|
self.accumulated_weight = 0 # That's weight **before** this entry
|
||||||
|
|
||||||
def is_file(self):
|
def is_file(self):
|
||||||
return self.sourcefs == "file"
|
return self.sourcefs == "file"
|
||||||
@ -395,6 +397,24 @@ def repair_root_permissions(root_mount_point):
|
|||||||
# But ignore it
|
# But ignore it
|
||||||
|
|
||||||
|
|
||||||
|
def extract_weight(entry):
|
||||||
|
"""
|
||||||
|
Given @p entry, a dict representing a single entry in
|
||||||
|
the *unpack* list, returns its weight (1, or whatever is
|
||||||
|
set if it is sensible).
|
||||||
|
"""
|
||||||
|
w = entry.get("weight", None)
|
||||||
|
if w:
|
||||||
|
try:
|
||||||
|
wi = int(w)
|
||||||
|
return wi if wi > 0 else 1
|
||||||
|
except ValueError:
|
||||||
|
utils.warning("*weight* setting {!r} is not valid.".format(w))
|
||||||
|
except TypeError:
|
||||||
|
utils.warning("*weight* setting {!r} must be number.".format(w))
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
"""
|
"""
|
||||||
Unsquash filesystem.
|
Unsquash filesystem.
|
||||||
@ -461,6 +481,8 @@ def run():
|
|||||||
unpack[-1].exclude = entry["exclude"]
|
unpack[-1].exclude = entry["exclude"]
|
||||||
if entry.get("excludeFile", None):
|
if entry.get("excludeFile", None):
|
||||||
unpack[-1].excludeFile = entry["excludeFile"]
|
unpack[-1].excludeFile = entry["excludeFile"]
|
||||||
|
unpack[-1].weight = extract_weight(entry)
|
||||||
|
unpack[-1].accumulated_weight = sum([e.weight for e in unpack[:-1]])
|
||||||
|
|
||||||
is_first = False
|
is_first = False
|
||||||
|
|
||||||
|
@ -32,6 +32,12 @@
|
|||||||
# - *excludeFile* is a single file that is passed to rsync as an
|
# - *excludeFile* is a single file that is passed to rsync as an
|
||||||
# --exclude-file argument. This should be a full pathname
|
# --exclude-file argument. This should be a full pathname
|
||||||
# inside the **host** filesystem.
|
# inside the **host** filesystem.
|
||||||
|
# - *weight* is useful when the entries take wildly different
|
||||||
|
# times to unpack (e.g. with a squashfs, and one single file)
|
||||||
|
# and the total weight of this module should be distributed
|
||||||
|
# differently between the entries. (This is only relevant when
|
||||||
|
# there is more than one entry; by default all the entries
|
||||||
|
# have the same weight, 1)
|
||||||
#
|
#
|
||||||
# EXAMPLES
|
# EXAMPLES
|
||||||
#
|
#
|
||||||
@ -85,8 +91,10 @@ unpack:
|
|||||||
- source: ../CHANGES
|
- source: ../CHANGES
|
||||||
sourcefs: file
|
sourcefs: file
|
||||||
destination: "/tmp/changes.txt"
|
destination: "/tmp/changes.txt"
|
||||||
|
weight: 1 # Single file
|
||||||
- source: src/qml/calamares/slideshow
|
- source: src/qml/calamares/slideshow
|
||||||
sourcefs: file
|
sourcefs: file
|
||||||
destination: "/tmp/slideshow/"
|
destination: "/tmp/slideshow/"
|
||||||
exclude: [ "*.qmlc", "qmldir" ]
|
exclude: [ "*.qmlc", "qmldir" ]
|
||||||
|
weight: 5 # Lots of files
|
||||||
# excludeFile: /etc/calamares/modules/unpackfs/exclude-list.txt
|
# excludeFile: /etc/calamares/modules/unpackfs/exclude-list.txt
|
||||||
|
Loading…
Reference in New Issue
Block a user