Bug 453450

Summary: Empty file being created even when receive operation fails
Product: [Applications] kdeconnect Reporter: jejoxe6725
Component: android-applicationAssignee: Albert Vaca Cintora <albertvaka>
Status: REPORTED ---    
Severity: normal CC: bugseforuns
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Android   
OS: Android 11.x   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description jejoxe6725 2022-05-06 04:05:17 UTC
SUMMARY
If receive operation fails from the senders side even before any file data is sent, then the receiver will create an empty file.

STEPS TO REPRODUCE
1. Grant all storage permission required to receive a file.
2. Send a file such that the receive operation fails due to some reason even before any bytes are received at the receiver end.
3. Check the folder where the file would have been saved had it been received correctly

OBSERVED RESULT
File of size 0 bytes is created.

EXPECTED RESULT
No file should be created.
Possible fix is to not call `openFile(...)` inside `if (numFiles == 1 && currentNetworkPacket.getBoolean("open", false))` at https://invent.kde.org/network/kdeconnect-android/-/blob/master/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeReceiveFileJob.java#L218
Comment 2 Patrick Silva 2022-05-06 13:48:50 UTC
Similar issue reported as bug 445703
Comment 3 jejoxe6725 2022-05-06 23:51:55 UTC
Right. But, the fix to both of them seem to be in different components.
- The fix to bug 445703 is probably in Dolphin or the component Dolphin internally uses.
- The fix to this bug is in kdeconnect-android (https://invent.kde.org/network/kdeconnect-android/-/blob/master/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeReceiveFileJob.java)