nlohmann / diarybot

DiaryBot
6 stars 1 forks source link

Import of .pages-files fails #1

Closed arbyter closed 10 years ago

arbyter commented 10 years ago

When a imessages contains "files" in a special format (only osx handels them as files but the are stored as folders) the import fails.

  File "./update_db.py", line 71, in <module>
    pic = open(full_filename)
IOError: [Errno 21] Is a directory: u'/Users/marcus/Library/Messages/Attachments/bc/12/95EF69C5-E69D-41C8-9420-F4B172F60425/Hausarbeit Neuartigkeitssprechakt - Marcus.pages'

``` 
nlohmann commented 10 years ago

Cannot reproduce. I imported a Pages file and could import it w/o problems. Here is the output of CouchDB:

{
  "total_rows": 39369,
  "offset": 39368,
  "rows": [
    {
      "id": "6AC17C3E-4D33-430E-A460-06F675C49681",
      "key": 1412712448,
      "value": {
        "_id": "6AC17C3E-4D33-430E-A460-06F675C49681",
        "_rev": "1-ea1755a0505fa49c7cb748ead7941b92",
        "from": "+4917662003111",
        "text": "",
        "rowid": 6283,
        "date": "2014-10-07T22:07:28",
        "id": "6AC17C3E-4D33-430E-A460-06F675C49681",
        "_attachments": {
          "attachment.zip": {
            "content_type": "application/zip",
            "revpos": 1,
            "digest": "md5-Ipw8Dsvwb5uf1gnuy8VNhg==",
            "length": 82924,
            "stub": true
          }
        }
      }
    }
  ]
}

I can download the linked file. After unzipping attachment.zip, I get the original Pages file.

@arbyter, can you check the MIME type of the file on your system?

arbyter commented 10 years ago

Result of file -I "/Users/marcus/Library/Messages/Attachments/bc/12/95EF69C5-E69D-41C8-9420-F4B172F60425/Hausarbeit Neuartigkeitssprechakt - Marcus.pages"

/Users/marcus/Library/Messages/Attachments/bc/12/95EF69C5-E69D-41C8-9420-F4B172F60425/Hausarbeit Neuartigkeitssprechakt - Marcus.pages: application/x-directory; charset=binary

nlohmann commented 10 years ago

The file arrived at me as "Mein schönes Dokument.pages.zip: Zip archive data, at least v1.0 to extract".

nlohmann commented 10 years ago

It seems as if iMessage automatically sends Bundles as ZIP:

screenshot 2014-10-07 22 39 47

nlohmann commented 10 years ago

Fixed in recent 2.0 commit: attachments are now automatically zipped if they are not single files.