-
Notifications
You must be signed in to change notification settings - Fork 21
Validate storage show warnings #789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,6 +220,27 @@ export const partitioningConfigureWithTask = ({ partitioning }) => { | |
); | ||
}; | ||
|
||
const partitioningValidate = async ({ onFail, onSuccess, partitioning }) => { | ||
const tasks = await new StorageClient().client.call( | ||
partitioning, | ||
INTERFACE_NAME_PARTITIONING, | ||
"ValidateWithTask", [] | ||
); | ||
return runStorageTask({ | ||
onFail, | ||
onSuccess: async () => { | ||
const taskProxy = new StorageClient().client.proxy( | ||
"org.fedoraproject.Anaconda.Task", | ||
tasks[0] | ||
); | ||
const result = await taskProxy.GetResult(); | ||
|
||
return onSuccess(result.v); | ||
}, | ||
task: tasks[0], | ||
}); | ||
}; | ||
|
||
export const resetPartitioning = () => { | ||
return callClient("ResetPartitioning", []); | ||
}; | ||
|
@@ -280,13 +301,24 @@ export const applyStorage = async ({ devices, luks, onFail, onSuccess, partition | |
await setBootloaderDrive({ drive: "" }); | ||
} | ||
|
||
const tasks = await partitioningConfigureWithTask({ partitioning }); | ||
const configureTasks = await partitioningConfigureWithTask({ partitioning }); | ||
|
||
const onConfigureTaskSuccess = async () => { | ||
try { | ||
await applyPartitioning({ partitioning }); | ||
await partitioningValidate({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @KKoukiou @adamkankovsky May I ask why we validate partitioning after applying it? In the Gtk backend we do it before: https://github.com/rhinstaller/anaconda/blob/1d9120e716aff354c7895ebde205f4ba6f9f347a/pyanaconda/ui/lib/storage.py#L307 |
||
onFail, | ||
onSuccess, | ||
partitioning, | ||
}); | ||
} catch (error) { | ||
onFail(error); | ||
} | ||
}; | ||
|
||
runStorageTask({ | ||
onFail, | ||
onSuccess: () => applyPartitioning({ partitioning }) | ||
.then(onSuccess) | ||
.catch(onFail), | ||
task: tasks[0] | ||
onSuccess: onConfigureTaskSuccess, | ||
task: configureTasks[0], | ||
}); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (complexity): Consider flattening the async flow by combining storage task calls into a single async/await block.
Consider flattening the async flow by combining the storage task calls into a single async/await block. For example, rather than nesting callbacks in both the
onConfigureTaskSuccess
and thepartitioningValidate
helper, inline the operations sequentially. This makes the flow of operations easier to follow. For instance:In this refactoring, the sequence is linear without multiple layers of callbacks. This keeps all behavior intact while reducing indirection and simplifying error handling.