Bug 505728

Summary: Make "Cancel" possible within an operation, when clicked at a convenient point
Product: [Applications] partitionmanager Reporter: ulterno
Component: generalAssignee: Andrius Štikonas <andrius>
Status: CONFIRMED ---    
Severity: wishlist    
Priority: NOR    
Version First Reported In: 25.04.1   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description ulterno 2025-06-18 07:55:30 UTC
SUMMARY
Certain operations have a "Check file system ..." operation right at the start, which is not causing any changes that might be a problem if the rest of the processes are not run.
It would be good if the user had the option to cancel during that operation, causing it to skip all the rest of the operations.

STEPS TO REPRODUCE
1. Setup a Move Partition (left) + Resize operation and "Apply"
2. During the "Check file system on partition /dev/sdx#" operation, press "Cancel"
3. Wait for the file system check to complete

OBSERVED RESULT
- After the file system check completes, partitionmanager will disregard the "Cancel" request and continue with the next operation of "Set geometry" which now makes it not convenient to interrupt

EXPECTED RESULT
- After the file system check completes, partitionmanager should check whether the "Cancel" button has been clicked and if the previous operations haven't yet made it inconvenient to interrupt, then interrupt before the "Set geometry" operation

SOFTWARE/OS VERSIONS
Operating System: EndeavourOS 
KDE Plasma Version: 6.3.5
KDE Frameworks Version: 6.14.0
Qt Version: 6.9.0
Kernel Version: 6.14.7-arch2-1 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 5800X 8-Core Processor
Memory: 62.7 GiB of RAM
Graphics Processor: AMD Radeon RX 7600

ADDITIONAL INFORMATION
- It will probably cancel after the move operation is finished and before the resize operation is started, in this case (need to wait until tomorrow to know)
Comment 1 Andrius Štikonas 2025-06-18 18:46:33 UTC
Yeah, something seems to be broken, I thought it already behaves as you described. Must be some regression.
Comment 2 Andrius Štikonas 2025-06-18 21:01:18 UTC
Oh apparently it was never supported... Check points are indeed only at the end of the operation.

One would have to insert checkpoints into each operation::execute function at appropriate places, e.g. for resizeoperation need to look at

https://invent.kde.org/system/kpmcore/-/blob/master/src/ops/resizeoperation.cpp?ref_type=heads#L140

and insert something like https://invent.kde.org/system/kpmcore/-/blob/dffcfa31054576a21411125be7c9634dc12432e7/src/core/operationrunner.cpp#L56

There are some minor problems:
isCancelling is only available from OperationRunner, not available in operations classes, so we would have to make it available there somehow. But at the same time, OperationRunner is not required to use Operations, e.g. Calamares installer uses KPMcore operations but not OperationRunner. Perhaps one could pass a pointer to Operation::execute() that is nullptr by default. And then checkpoint is only checked if pointer to OperationRunner is not null.