Permalink
Browse files

ticket 528 show dialog on windows' failed permissions on save

  • Loading branch information...
1 parent d2abc28 commit 1b84498505802b9590f3e3a5d9b7d446a9a1bfb2 @rdp rdp committed May 16, 2011
Showing with 11 additions and 3 deletions.
  1. +11 −3 plugins/project/lib/project/commands.rb
View
14 plugins/project/lib/project/commands.rb
@@ -152,13 +152,21 @@ def execute
path = tab.edit_view.document.mirror.path
dir = File.dirname(path)
writable_file = File.writable?(path)
- writable_dir = File.writable?(dir)
+ writable_dir = File.writable?(dir) # this method buggy in windows: http://redmine.ruby-lang.org/issues/4712
file_exists = File.exist?(path)
can_write = writable_file || (!file_exists && writable_dir)
if can_write
- tab.edit_view.document.save!
- Project::Manager.refresh_modified_file(tab.edit_view.document.mirror.path)
+ begin
+ tab.edit_view.document.save!
+ Project::Manager.refresh_modified_file(tab.edit_view.document.mirror.path)
+ rescue Errno::EACCES # windows
+ show_dialog = true
+ end
else
+ show_dialog = true
+ end
+
+ if show_dialog
Application::Dialog.message_box(
"Can't save #{tab.edit_view.document.mirror.path}, you don't have the permissions.",
:type => :error,

0 comments on commit 1b84498

Please sign in to comment.