revanced-cli icon indicating copy to clipboard operation
revanced-cli copied to clipboard

bug: Failed to delete temp files

Open EnricoTirri opened this issue 1 year ago • 0 comments

Bug description

  • When selecting "-p" option in order to purge temp files after patch, severe error appears on deleting and all classes.dex files are preserved.

Error logs

No response

Solution

Seams like after

PatchCommand.kt :: 317
// region Save
apk.copyTo(temporaryFilesPath.resolve(apk.name), overwrite = true).apply {  
    patcherResult.applyTo(this)  
}  

All "files" contained in

patcherResult.dexFiles

Have streams open, and this prevents OS to delete them A possible solution, since that streams are not used anymore, is to close them one by one:

// region Save
apk.copyTo(temporaryFilesPath.resolve(apk.name), overwrite = true).apply {
    patcherResult.applyTo(this)
    patcherResult.dexFiles.forEach{it.stream.close()}
}

Additional context

No response

Acknowledgements

  • [X] This issue is not a duplicate of an existing bug report.
  • [X] I have chosen an appropriate title.
  • [X] All requested information has been provided properly.

EnricoTirri avatar Apr 06 '24 10:04 EnricoTirri