    @listen 'openFile', (entry, callback) ->
     console.log 'openFile', new Date
     return unless entry?
+    return if not entry.isFile
 
     chrome.storage.local.set
      file: chrome.fileSystem.retainEntry entry


    setTimeout reentrant, 100

   @listen 'openDirectory', (entry) ->
    return unless entry?

    chrome.storage.local.set
     directory: chrome.fileSystem.retainEntry entry

    @loadDirEntry entry

   @listen 'file', (e) ->
    chrome.fileSystem.chooseEntry

     reader.readAsDataURL file

   loadDirEntry: (entry, callback) ->
    dirs = [entry]
    n = 0

    readEntries = =>
     while true
      if n >= dirs.length
       return callback
      entry = dirs[n]
      ++n
      break if entry? and entry.isDirectory

     console.log entry.fullPath
     reader = entry.createReader()
     reader.readEntries =>
      for e in results
       if e.isDirectory
        dirs.push e
       else
        self.addResource e
      readEntries()
     , @on.error

    readEntries()

