bepaald / signalbackup-tools

Tool to work with Signal Backup files.
GNU General Public License v3.0
790 stars 38 forks source link

Try to save files with correct extension #232

Closed qwerty287 closed 1 month ago

qwerty287 commented 2 months ago

Hello,

first of all, I'm really happy that I found that. I tried another tool first because I had some troubles with compiling first (using cmake instead of g++ solved it for me, I don't know what the problem was) but it was not good. So I tried your tool again and it worked this time - and I really have to say I like it! Nice-looking HTML files, plenty of options… Big thanks!

Some note before I start: I only used the tool to extract chats from Signal Desktop, I didn't use an Android backup, so it's possible that the behavior is desktop-specific.

I just found one small issue that could also be a design decision (but I didn't find any other issue): All files are saved with a .bin extension. If you only work on the filesystem, that's not problem as you can just copy and rename the files and cmd tools like file also detect that correctly. Using it in the webbrowser from the HTML has its problem though. Firefox rejects opening files with this extension and only offers to download them, but I'd like to view them directly in my browser. If I'm already looking at the generated HTML that's much easier instead of having to search for the correct directory on my disk.

I know that Signal saves all files without extension, but restoring them should be possible. All avatars seem to be JPEGs (at least I didn't find something else) and file attachments have a name from which the extension can be extracted. If nothing works you could either fallback to file or just keep .bin, but having this for most files correct would help me a lot already.

However, that's just a small issue and it's not a big problem if you can't fix it - thanks for making this awesome tool!

bepaald commented 2 months ago

Hi!

When using the --dumpmedia option, I already (attempt to) set the correct extension, using a hardcoded list that maps mimetypes to extensions (https://github.com/bepaald/signalbackup-tools/blob/master/mimetypes/mimetypes.h). While Signal indeed usually doesn't save the extension, it does save the mimetype. Falling back to file (or magic) is not really an option I believe as it is not (normally) available on Windows, but the list works for almost anything you would normally encounter in Signal. (I have plenty of png avatars by the way, and I wouldn't be surprised if webp is also an option)

There was actually a reason I do not use the naming scheme from --dumpmedia when exporting to html, but I believe it only really applies to the basename of the filename, not the extension. So I'll investigate and see if I can make this work.

If you ever remember (or can reproduce) your problems compiling with g++, I'd love to hear them.

Thanks!

qwerty287 commented 2 months ago

Actually there wasn't any error with g++, just nothing happened. No output. I waited at least 5 min and also checked the CPU load, but there was nothing. So maybe I wasn't patient enough, but cmake builds it in a minute.

bepaald commented 2 months ago

Actually there wasn't any error with g++, just nothing happened. No output. I waited at least 5 min and also checked the CPU load, but there was nothing. So maybe I wasn't patient enough, but cmake builds it in a minute.

Yeah, that actually sound about right, running g++ directly is pretty slow (single process) and should not output anything unless there are problems in the code (which I hope there aren't), while cmake will use all your cores to compile sources in parallel. Results on my system are similar (~25 secs vs ~210 secs). Thanks for letting me know.

I started work on this, the attachments should now be written with (mostly) correct extensions. Work on the avatars is a bit more involved, I need some time to think about the best way to do that. But I'll report back when it's done.

bepaald commented 1 month ago

Ok, that was a more difficult than I thought, but a first attempt is now implemented. Proper extensions should be used for attachments, avatars and stickers now. Let me know if it works as you expect. Thanks!

qwerty287 commented 1 month ago

Yes, it works! Thanks for the fast fix!