atom / autosave

Autosaves buffers when they lose focus
MIT License
63 stars 29 forks source link

Uncaught Error: Can't create a backup file for /usr/local/texlive/2015/texmf-dist/tex/latex/xcolo... #50

Open eject-it opened 9 years ago

eject-it commented 9 years ago

[Enter steps to reproduce below:]

  1. Edit a file that is write protected file
  2. Try to save it under another filename.
  3. When the current window loses focus the Autosave kicks in
  4. Press cancel on the password dialog (which in (this case luckily) doesn't autofocus)
  5. Keep on pressing cancel while trying to extract the content ctr+a, ctr+c

And poof, there it goes. Will work everytime. It isn't really the fault of the autosave package. It is Atom itself that is not capable of dealing with write protected files. You can't save them elsewhere even when no autosave is being used it won't let you choose another destination. Why it brings up the password dialog in the first place is beyond me anyway. Even if I enter my sudo capable password it will not be able to edit a file of the type that has the write privs at 0 (like 600, 700, 400 whatever). It would propably need a privileged helper tool for that. System: Mac OS X 10.10.5 Thrown From: autosave package, v0.22.0

Stack Trace

Uncaught Error: Can't create a backup file for /usr/local/texlive/2015/texmf-dist/tex/latex/xcolor-solarized/xcolor-solarized.sty because files already exist at every candidate path.

At /Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:809

Error: Can't create a backup file for /usr/local/texlive/2015/texmf-dist/tex/latex/xcolor-solarized/xcolor-solarized.sty because files already exist at every candidate path.
  at TextBuffer.module.exports.TextBuffer.backUpFileContentsBeforeWriting (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1097:17)
  at TextBuffer.module.exports.TextBuffer.saveAs (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1020:31)
  at TextBuffer.module.exports.TextBuffer.save (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1004:19)
  at TextEditor.module.exports.TextEditor.save (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:584:26)
  at Pane.module.exports.Pane.saveItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:547:18)
  at Object.module.exports.autosavePaneItem (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/autosave/lib/autosave.js:64:21)
  at /Applications/Atom.app/Contents/Resources/app.asar/node_modules/autosave/lib/autosave.js:41:24
  at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:82:11)
  at PaneContainer.module.exports.PaneContainer.willDestroyPaneItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane-container.js:280:27)
  at Pane.module.exports.Pane.destroyItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:459:17)
  at HTMLDivElement.<anonymous> (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/tabs/lib/tab-bar-view.js:236:22)
  at space-pen-ul.jQuery.event.dispatch (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/jquery/dist/jquery.js:4435:9)
  at space-pen-ul.elemData.handle (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/jquery/dist/jquery.js:4121:28)
  at EventEmitter.ipc.sendSync (/Applications/Atom.app/Contents/Resources/atom.asar/renderer/api/lib/ipc.js:21:31)
  at BrowserWindow.RemoteMemberFunction [as getPosition] (/Applications/Atom.app/Contents/Resources/atom.asar/renderer/api/lib/remote.js:140:29)
  at Atom.module.exports.Atom.getWindowDimensions (/Applications/Atom.app/Contents/Resources/app.asar/src/atom.js:555:29)
  at Atom.module.exports.Atom.storeDefaultWindowDimensions (/Applications/Atom.app/Contents/Resources/app.asar/src/atom.js:588:25)
  at /Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:104:21
  at handler (/Applications/Atom.app/Contents/Resources/app.asar/src/space-pen-extensions.js:115:32)
  at jQuery.event.dispatch (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/space-pen/vendor/jquery.js:4681:9)
  at elemData.handle (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/space-pen/vendor/jquery.js:4359:46)

Commands

  3x -2:43.3.0 core:backspace (atom-text-editor.editor.is-focused)
     -2:42.1.0 core:delete (atom-text-editor.editor.is-focused)
     -2:40.6.0 core:move-down (atom-text-editor.editor.is-focused)
     -2:40 core:move-right (atom-text-editor.editor.is-focused)
     -2:39.5.0 core:move-down (atom-text-editor.editor.is-focused)
  2x -2:39.2.0 core:move-right (atom-text-editor.editor.is-focused)
     -2:38.2.0 core:delete (atom-text-editor.editor.is-focused)
     -2:37.8.0 core:move-down (atom-text-editor.editor.is-focused)
     -2:36.6.0 core:delete (atom-text-editor.editor.is-focused)
  2x -2:36.2.0 core:backspace (atom-text-editor.editor.is-focused)
     -2:35.2.0 core:move-down (atom-text-editor.editor.is-focused)
  3x -2:34.4.0 core:delete (atom-text-editor.editor.is-focused)
     -2:32.1.0 core:move-down (atom-text-editor.editor.is-focused)
     -2:31.6.0 core:move-right (atom-text-editor.editor.is-focused)
  2x -2:31 core:delete (atom-text-editor.editor.is-focused)
  6x -2:10.7.0 core:copy (atom-text-editor.editor.is-focused)

Config

{
  "core": {
    "disabledPackages": [
      "about",
      "language-go",
      "language-git",
      "language-java",
      "language-javascript",
      "language-less",
      "language-mustache",
      "language-php",
      "language-sass",
      "language-yaml",
      "language-todo",
      "metrics",
      "release-notes",
      "link",
      "preview-inline",
      "language-css",
      "language-csharp",
      "language-coffee-script",
      "language-clojure",
      "language-c",
      "language-sql"
    ],
    "packagesWithKeymapsDisabled": [
      "latex-plus",
      "linter"
    ],
    "themes": [
      "one-dark-ui",
      "base16-tomorrow-dark-theme"
    ]
  },
  "autosave": {
    "enabled": true
  }
}

Installed Packages

# User
atom-beautify, v0.28.14
autocomplete-bibtex, v0.6.1
bottom-dock, v0.3.5
file-watcher, v0.4.0
highlight-selected, v0.10.1
language-latex, v0.6.1
language-lua, v0.9.4
latex, v0.26.0
latex-completions, v0.3.0
latexer, v0.2.7
linter, v1.8.1
linter-chktex, v1.1.3
linter-manager, v0.2.3
markdown-preview-plus, v2.2.2
minimap, v4.13.4
minimap-highlight-selected, v4.3.1
pretty-json, v0.4.1

# Dev
No dev packages
winstliu commented 9 years ago

/cc @nathansobo

nathansobo commented 9 years ago

This looks like it's actually an issue with creating backup files in write-protected directories. We should probably check that we have permission before attempting to create one. As a workaround you can disable backup before saving when editing in these kinds of situations.

eject-it commented 9 years ago

How about declaring a backup directory? obviously there would need to be a few check involved as well. Otherwise it might attempt creating a copy of some ridiculously large file, probably binary, that was opened by mistake.

nathansobo commented 9 years ago

How about declaring a backup directory?

That could work, although part of the value of this simple implementation is that if something goes wrong, your backup file is sitting right next to the original with a ~ appended to it and is easy to find. If we go to a backup directory, we may need to implement a command like recover-from-backup or something to help people.