carderne / signal-export

Export your Signal chats to markdown files with attachments
Other
481 stars 50 forks source link

Photos not being exported #15

Closed pfeiffee closed 3 years ago

pfeiffee commented 3 years ago

When I run the command:

python3 /signal-export/sigexport.py --overwrite --manual --source /home/singleuser/.config/Signal/ --old /database/Signal0 /database/Signal0

All the chat text exports successfully, but none of the pictures export.

I get the error:

  File "/signal-export/sigexport.py", line 577, in <module>
    main()
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/signal-export/sigexport.py", line 569, in main
    merge_with_old(dest, Path(old))
  File "/signal-export/sigexport.py", line 468, in merge_with_old
    merge_attachments(sub / "media", dir_old / "media")
  File "/signal-export/sigexport.py", line 428, in merge_attachments
    shutil.copy2(f, media_new)
  File "/usr/lib/python3.8/shutil.py", line 432, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.8/shutil.py", line 241, in copyfile
    raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: PosixPath('/database/Signal0/person/media/2021-05-20_None') and '/database/Signal0/person/media/2021-05-20_None' are the same file

"2021-05-20_None" is actually a .jpg file that can be opened in a normal image viewer and is the most recent image in the chat log. Perhaps _None needs to be auto generated by a md5 of the image file content on error or some other id from the DB?

carderne commented 3 years ago

Hi @pfeiffee, I think this is because of how you've run the command. Because I'm not 100% confident of the merging code, it is designed so that the --old directory should be different from the new output directory. If you change the last directory in your call to e.g. /database/Signal1 then it should work.

I understand it would be desirable to just merge the old one in place, but I'm nervous of deleting people's archives (including my own) and I haven't spent enough time on the code to check all edge cases. In the meantime I'll add something to the README clarifying this.

Please let me know if that works.