MaxiHuHe04 / iTunes-Backup-Explorer

A graphical tool that can extract and replace files from encrypted and non-encrypted iOS backups
MIT License
457 stars 37 forks source link

Large exports fail after a time with no error #12

Closed tetrahedrl closed 1 year ago

tetrahedrl commented 1 year ago

Hi, trying to export my SMS attachments (on windows).

I select MediaDomain/Library/SMS/Attachments, it works for a while trying to export, then the progress bar unceremoniously closes and the tasbar icon blinks orange, no error box. A significant amount of it does get exported, but much of it doesn't. All of the folders one step below attachments get created, but some of these are left empty.

I suspect it's having trouble with specific files, because...

Is there any kind of logging I can turn on to find the specific files it's failing on? Thanks.

MaxiHuHe04 commented 1 year ago

Hey @tetrahedrl! That sounds interesting. Could you try exporting the folder again after launching the program using the command java -jar itunes-backup-explorer-1.2.jar in a terminal? This should hopefully give us some logs.

tetrahedrl commented 1 year ago

It looks like the issue is file names that are okay on iOS, but invalid on Windows.

I tried running from Windows Terminal, where it gave no message when the export failed. So I went ahead and cloned the repo, added a line of code printing the filename in the for loop at exportFiles(List<BackupFile> files, File destination) in FilesTabController.java and let it run. The last file it attempted before stopping was named cm-chat-media-video-1:a15bd878-dc03-5591-864c-cec5096a6b77:609:0:0.MOV, which was also the last attempted when picking just the /39/09 subfolder it was in. Attempting to export the file on its own was where I realized this issue, as Windows didn't let me use the autofilled file name due to the : character.

The video file works perfectly fine if I export it on its own and specify a different filename. I assume to solve this, we just need to remove special characters in filenames before trying to save them in bulk exports.

tetrahedrl commented 1 year ago

From messing around with printing debug info as it steps through (can't get my debugger working to use breakpoints haha), it seems the place things first go wrong with this filename at

String relative = withRelativePath ? Paths.get(this.domain, this.relativePath).toString() : this.getFileName();

in

public void extractToFolder(File destinationFolder, boolean withRelativePath)

in BackupFile.java, when this.relativePath is Library/SMS/Attachments/39/09/71A2C810-207D-4175-82A4-93274D00028F/cm-chat-media-video-1:a15bd878-dc03-5591-864c-cec5096a6b77:609:0:0.MOV and this.getFileName() returns cm-chat-media-video-1:a15bd878-dc03-5591-864c-cec5096a6b77:609:0:0.MOV

Paths throws an InvalidPathException when it sees the invalid character :

tetrahedrl commented 1 year ago

Addressed (not sure if for all cases) in #13