Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting iOS backups may ignore -c compatible #296

Closed
ReagentX opened this issue Jul 21, 2024 Discussed in #295 · 3 comments · Fixed by #297
Closed

Exporting iOS backups may ignore -c compatible #296

ReagentX opened this issue Jul 21, 2024 Discussed in #295 · 3 comments · Fixed by #297
Assignees
Labels
bug Something isn't working crate: cli Related to the CLI crate exporter Related to exporter processes

Comments

@ReagentX
Copy link
Owner

Discussed in #295

Originally posted by macramores July 21, 2024
I can create a backup from my Mac and it correctly converts the -c compatible correctly, but when trying to create a backup from an iOS backup, it pulls the backup in 10 seconds (which is impressive) but ignores the -c compatible. Here's the line I'm running:

./imessage-exporter -f html -p ~/iphone_backup_latest/00008030-001445C43E60A02E -a iOS -o backup_export -c compatible

Thank you!

@ReagentX ReagentX added crate: cli Related to the CLI crate exporter Related to exporter processes labels Jul 21, 2024
@ReagentX ReagentX self-assigned this Jul 21, 2024
@ReagentX ReagentX moved this to In Progress in 2.0: California Poppy Jul 21, 2024
@ReagentX ReagentX changed the title iOS Backup may ignore -c compatible Exporting iOS backups may ignore -c compatible Jul 21, 2024
@ReagentX ReagentX added the bug Something isn't working label Jul 21, 2024
@ReagentX
Copy link
Owner Author

ReagentX commented Jul 21, 2024

Report indicates HEIF extension files are not converted:

// Normal attachments always get converted to jpeg
else if original_extension == "heic" || original_extension == "HEIC" {
let output_type = ImageType::Jpeg;
// Update extension for conversion
to.set_extension(output_type.to_str());
if convert_heic(from, to, converter, &output_type).is_none() {
eprintln!("Unable to convert {from:?}");
}
} else {
Self::copy_raw(from, to);
}

@ReagentX
Copy link
Owner Author

On iOS, attachment files are stored with names as hashes without extensions, so the current detection code doesn't work in those cases:

/// Generate an iOS path for an attachment
fn gen_ios_attachment(file_path: &str, db_path: &Path) -> Option<String> {
let input = file_path.get(2..)?;
let filename = format!(
"{:x}",
Sha1::digest(format!("MediaDomain-{input}").as_bytes())
);
let directory = filename.get(0..2)?;
Some(format!("{}/{directory}/{filename}", db_path.display()))
}

@ReagentX
Copy link
Owner Author

ReagentX commented Jul 21, 2024

We can use the mime_type to parse the file type from the Attachment:

/// Get the media type of an attachment
pub fn mime_type(&'_ self) -> MediaType<'_> {
match &self.mime_type {
Some(mime) => {
if let Some(mime_str) = mime.split('/').next() {
match mime_str {
"image" => MediaType::Image(mime),
"video" => MediaType::Video(mime),
"audio" => MediaType::Audio(mime),
"text" => MediaType::Text(mime),
"application" => MediaType::Application(mime),
_ => MediaType::Other(mime),
}
} else {
MediaType::Other(mime)
}
}
None => {
// Fallback to `uti` if the MIME type cannot be inferred
if let Some(uti) = &self.uti {
match uti.as_str() {
// This type is for audio messages, which are sent in `caf` format
// https://developer.apple.com/library/archive/documentation/MusicAudio/Reference/CAFSpec/CAF_overview/CAF_overview.html
"com.apple.coreaudio-format" => MediaType::Audio("x-caf; codecs=opus"),
_ => MediaType::Unknown,
}
} else {
MediaType::Unknown
}
}
}
}

We should use this to determine if the file should be converted or not.

ReagentX added a commit that referenced this issue Jul 21, 2024
ReagentX added a commit that referenced this issue Jul 21, 2024
@ReagentX ReagentX moved this from In Progress to Done in 2.0: California Poppy Jul 21, 2024
KevinPBurke pushed a commit to KevinPBurke/imessage-exporter that referenced this issue Aug 12, 2024
KevinPBurke pushed a commit to KevinPBurke/imessage-exporter that referenced this issue Aug 12, 2024
KevinPBurke pushed a commit to KevinPBurke/imessage-exporter that referenced this issue Aug 12, 2024
KevinPBurke pushed a commit to KevinPBurke/imessage-exporter that referenced this issue Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crate: cli Related to the CLI crate exporter Related to exporter processes
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

1 participant