mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-19 00:27:21 +00:00
sculpt_manager: 'File_operation_queue' enhancement
This patch add the support needed for implementing on-target system-update functionality. The new 'empty' method is required for the two-step procedure of updating image-index files - removing the old index, followed by downloading the most current one. It is used to the detect the completion of the first step. Issue #4744
This commit is contained in:
parent
60a089d795
commit
6b3c7c9a6c
@ -32,19 +32,34 @@ struct Sculpt::File_operation_queue : Noncopyable
|
||||
|
||||
State state { State::PENDING };
|
||||
|
||||
enum class Type { REMOVE_FILE } type;
|
||||
enum class Type { REMOVE_FILE, COPY_ALL_FILES } type;
|
||||
|
||||
Path const path;
|
||||
Path const from { };
|
||||
Path const path; /* destination */
|
||||
|
||||
Operation(Type type, Path const &path) : type(type), path(path) { }
|
||||
|
||||
Operation(Type type, Path const &from, Path const &to)
|
||||
: type(type), from(from), path(to) { }
|
||||
|
||||
void gen_fs_tool_config(Xml_generator &xml) const
|
||||
{
|
||||
if (state != State::IN_PROGRESS)
|
||||
return;
|
||||
|
||||
xml.node("remove-file", [&] () {
|
||||
xml.attribute("path", path); });
|
||||
switch (type) {
|
||||
|
||||
case Type::REMOVE_FILE:
|
||||
xml.node("remove-file", [&] {
|
||||
xml.attribute("path", path); });
|
||||
break;
|
||||
|
||||
case Type::COPY_ALL_FILES:
|
||||
xml.node("copy-all-files", [&] {
|
||||
xml.attribute("from", from);
|
||||
xml.attribute("to", path); });
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -64,7 +79,25 @@ struct Sculpt::File_operation_queue : Noncopyable
|
||||
if (already_exists)
|
||||
return;
|
||||
|
||||
new (_alloc) Registered<Operation>(_operations, Operation::Type::REMOVE_FILE, path);
|
||||
new (_alloc) Registered<Operation>(_operations,
|
||||
Operation::Type::REMOVE_FILE, path);
|
||||
}
|
||||
|
||||
void copy_all_files(Path const &from, Path const &to)
|
||||
{
|
||||
new (_alloc) Registered<Operation>(_operations,
|
||||
Operation::Type::COPY_ALL_FILES, from, to);
|
||||
}
|
||||
|
||||
bool copying_to_path(Path const &path) const
|
||||
{
|
||||
bool result = false;
|
||||
_operations.for_each([&] (Operation const &operation) {
|
||||
if (operation.path == path)
|
||||
if (operation.type == Operation::Type::COPY_ALL_FILES)
|
||||
result = true; });
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool any_operation_in_progress() const
|
||||
@ -77,6 +110,13 @@ struct Sculpt::File_operation_queue : Noncopyable
|
||||
return any_in_progress;
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
bool result = true;
|
||||
_operations.for_each([&] (Operation const &) { result = false; });
|
||||
return result;
|
||||
}
|
||||
|
||||
void schedule_next_operations()
|
||||
{
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user