cs150bf / ever-notedown

Atom Editor Plugin
MIT License
140 stars 13 forks source link

Syncing issue (Evernote sync icon spins indefinitely) #15

Open 7k50 opened 8 years ago

7k50 commented 8 years ago

EVND has worked quite well the short while I have been testing it. But I was working on a Markdown file in Atom that was synced to Evernote, and when I saved to a new file (Save As), I can no longer sync anything. Not the new file and not the old one, or anything else.

What happens is just that the Evernote icon for sync (the elephant), turns into a yellow wheel that spins indefinitely. Every time I press sync, an empty copy of the note is created in Evernote. The note has the right name, but no content. So in effect, my Evernote is being spammed with empty notes.

Trying to create new notes do not help, the same issue persists. Quitting/Restarting Atom and Evernote does nothing, neither does it help to delete the EVND files or the Evernote notes.

cs150bf commented 8 years ago

That sounds really painful, I'm sorry to hear that.

I cannot exactly duplicate your problem - when I tried "Save as" and sync'd again, EVND created a new note but only for once, with right name and reasonable content. I did see the sync icon spinning indefinitely, but re-opening the old file solves the problem for me.

At this point my best guess is that there are some bug in EVND's file operation and it somehow confused itself. Before I figure this out and come up with a fix (which I cannot promise...), but a log would help. Could you copy & paste some log from Atom when you trigger the problem? (From the menu bar, View -> Developer -> Toggle developer tools, or alt + cmd + i). Hopefully there will be some highlighted error message from EVND. (Example)

 

There are also a few things that you might want to try:

Option 1: rollback. Since the default EVND directory is implemented as a git directory, theoretically it should be easy to go back to any point you want.

  1. Navigate to your notes directory (default to ~/.atom/evnd/)
  2. View git log with
$ git log --date=iso --pretty=format:'%C(magenta)%h%Creset %C(red)[%ad]%C(auto)%d%Creset %s %C(blue)<%an>%Creset'

or

git log --pretty=format:"%h [%cd] %s"
  1. Find the commit that happened right before the "Save as" operation, revert to that point (this will not have any effect on the file you saved to some other place -- as long as it's not in the EVND folder).

Option 2: start anew If you don't like the trouble with git but still would like to give EVND a try, you can back up your EVND folder (deafult to ~/.atom/evnd/) and move/delete/rename it when Atom & EVND are NOT running. Then the next time you open Atom & EVND everything should start anew. This will not effect the notes created with EVND and already sync'd to Evernote -- except that you won't be able to edit them with EVND without importing first...

Option 3: If you don't like dealing with git and don't like Option 2, you may also try manually edit the note index file (default location: ~/.atom/evnd/index.json). Open the file with any text editor when Atom & EVND are NOT running, you will see a bunch of entries like this:

{
    "[Note ID: 218bd3428blahblahblahblah]": {
        "creationTime": "2015-10-05 21:38:53",
        "enCreationDate": "20151005T213854",
        "lastSyncDate": "20151005T213856",
        "enModificationDate": "20151005T213856",
        "modificationTime": "2015-10-05 21:39:00",
        "metaDate": null,
        "dir": "20151005/",
        "path": "somethingsomething/20151005",
        "title": "EVND Debug Issue 15",
        "noteLink": null,
        "tags": [
            "evnd"
        ],
        "notebook": {
            "name": "Inbox",
            "type": "synchronized"
        },
        "enExportedFiles": [
            "somethingsomething/20151005/evnd_debug_issue_15_20151005_213853_evernote.html/",
            "somethingsomething//20151005/evnd_debug_issue_15_20151005_213853_evernote.enex"
        ],
        "format": "Markdown",
        "fnStem": "evnd_debug_issue_15_20151005_213853",
        "enml": null,
        "attachments": {},
        "addAttachments": false,
        "text": null,
        "html": null,
        "rawHTML": null,
        "css": null,
        "syncdContent": null,
        "id": "[Note ID: 218bd34287da3d809c41dd93f1b45d3d]",
        "header": "<head><title>EVND Debug Issue 15</title><link rel=\"stylesheet\" type=\"text/css\" href=\"somethingsomething/20151005/evnd_debug_issue_15_20151005_213853_style.css\"></head>",
        "queryString": "[Note ID: 218bd34287blahblah] created:20151005T213852 -created:20151005T213856",
        "renderOptions": {
            "mathjax": true
        },
        "contentMD5": "a079e340dbe30525c4c568c6738d820d",
        "dontChangeTime": true,
        "filePath": "/somethingsomething/20151005/evnd_debug_issue_15_20151005_213853.markdown",
        "moved": false
    }
}

If the file isn't too long, you might be able to spot the offending entries (duplicate entries with the same Note ID? dupliate entries with the same filePath? etc.) and removing them should fix the problem. This sounds really tedious, though, so I don't know...

7k50 commented 8 years ago

Thanks for your swift reply! And for taking time to develop this package which is very useful for me.

Here's what I have tried:

Option 2 – Removed EVND from the .atom directory and a new folder was created at startup, but did not help with the syncing issue.

Option 3 – I have already tried to delete all notes in EVND (I didn't have that many), so index.json had only one note in it which is a newly-created test-note I'm using to attempt sync.

I would like to try Option 1, but I'm unsure what the proper command line is to rollback with git. I found a time location (a checksum code) in the git log which I would like to roll back to.

Also, this seems to be the typical error that is being displayed in the Dev log when trying to sync:

/Users/winterflags/.atom/packages/ever-notedown/lib/evernote-helper.coffee:691 Error: Command failed: /bin/sh -c osascript /var/folders/z7/z662sk6s0ss2mtzyhvmwfyf80000gn/T/evernote-create-note-temp11596-64510-rgh56i.AppleScript

/var/folders/z7/z662sk6s0ss2mtzyhvmwfyf80000gn/T/evernote-create-note-temp11596-64510-rgh56i.AppleScript:347:428: execution error: Evernote got an error: Could not parse ENML (4)

    at ChildProcess.exithandler (child_process.js:208:12)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:764:16)
    at Socket.<anonymous> (internal/child_process.js:319:11)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at Pipe._onclose (net.js:467:12)(anonymous function) @ /Users/winterflags/.atom/packages/ever-notedown/lib/everno
cs150bf commented 8 years ago

Well, thank you for your feedback! The error log is very helpful. It seems that the problem might actually be caused by something different from what I initially thought. It's very curious that Evernote returns error message like execution error: Evernote got an error: Could not parse ENML (4).

Would you mind checking a few things?

  1. Which version of Evernote client are you using?
  2. What's the content of your evnd/tmp/evernote-create-note.AppleScript? It should look something like this (the path to the ENML file is most relevant):
.
.
.
blah blah
.
.
.

set newcontent to readFile("/Users/<myname>/Documents/EVND/20151005/evnd_debug_issue_15_20151005_213853.enml")
set infostr to ""
tell application "Evernote"
    set note1 to create note title "EVND Debug Issue 15" with enml newcontent tags {"EVND"} 
    if (notebook named "Inbox" exists) then
        move note1 to notebook "Inbox"
    else
        set infostr to infostr & "(notebook does not exist)"
    end if
    set source URL of note1 to "/Users/<myname>/Documents/EVND/20151005/evnd_debug_issue_15_20151005_213853.enml"
    set date1 to creation date of note1
end tell

.
.
.
blah blah
.
.
.
  1. What is the content of the ENML file? I'm not sure what could cause the Could not parse ENML (4) error. It would be very helpful if you could post (or email me) the content--feel free to black out anything you do not wish to share.

 

P.S. At this point I'm not sure if rolling back would fix the problem--but if you still want to try that, I think something like $ git checkout -b goodolddays 01abcdefg should work (replace the last string with the commit that you want to roll back to).

Rolling back with git:

7k50 commented 8 years ago

The Evernote version is Version 6.1.1 (452253 Direct) for OS X El Capitan 10.11.

There seems to be something in the note itself that causes the parse ENML error.

I successfully rolled back to a previous git state and could sync new notes to Evernote again. But moments later when copy/pasting back the content in the note I was working on before the sync errors started, the same problem started again.

The note contents and ENML file are pretty large so I will have emailed them to you.

cs150bf commented 8 years ago

I guess I should write some notes here as a follow-up to this issue. Apparently more sanity checks need to be done before sending the rendered ENML to the Evernote client. This particular problem seems to have stem from the fact that the raw note text contains HTML <br \> (note the backslash). I'm not sure how did that broke syncing for other notes, though.

TODO:

cfurrow commented 8 years ago

I had an issue like this, and when I switch from the Mac App Store version of Evernote, to one downloaded directly from Evernote.com, the issue went away. I think there may be a sandboxing issue w/ the App Store that prevents the Evernote app from reading the Ever Notedown files:

(In the Console app):

Evernote(20964) deny file-write-create /Users/carl/ever_notedown/20160327/2016_03_27.enex

image

hoodsy commented 7 years ago

Installing the non-App Store version of Evernote fixed this for me.