mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-05 11:30:47 -05:00
processFile handled two different jobs in one function, sharing variables and try/catch blocks: patching a tar archive into a new tar, and extracting a boot image into a patched .img. It also opened the input twice, as a stream for detection and as a channel for the extractors. processUrl separately repeated a zip-only copy of the image path. Open the input once as a DataChannel: DataChannel.File for a URI and DataChannel.Http for a URL. Everything after that is one pipeline: processInput reads the header with a positional read and dispatches to processArchive (tar in, tar out) or extractAndProcessImage (payload, zip or raw image in, image out). As a result, URLs now accept every format that files do. Additionally: - Rename DataChannel.sliceStream to stream, and add a zero-arg stream() that covers the entire channel. - Make TarProcessor.consume take a DataChannel and close it, matching the extractors. - Close the input ParcelFileDescriptor instead of leaking it. - Report output file creation failures on the URL path instead of crashing. Assisted-by: Claude Opus 5.5