booh-classifier: check permissions for removal and move so as not to lose classificat...
authorGuillaume Cottenceau <gcottenc@gmail.com>
Sun, 14 Dec 2008 14:16:16 +0000 (15:16 +0100)
committerGuillaume Cottenceau <gcottenc@gmail.com>
Sun, 14 Dec 2008 14:16:16 +0000 (15:16 +0100)
TODO
bin/booh-classifier

diff --git a/TODO b/TODO
index 6086f71..69f27b5 100644 (file)
--- a/TODO
+++ b/TODO
@@ -12,6 +12,3 @@
 
 when you merge current dir, startup may be very slow (many files
 in dir?) without the progressbar moving, we think it's frozen/dead..
-
-when user doesn't have permissions to modify stuff, don't fail
-current way e.g. lose all work done..
index 558c444..79bd95a 100755 (executable)
@@ -902,6 +902,9 @@ def thumbnail_keypressed(entry, event)
         label_before = entry.labeled
 
         if event.keyval == Gdk::Keyval::GDK_Delete
+            if ! FileTest.writable?(entry.path)
+                show_popup($main_window, utf8(_("Notice: no write access to '%s', permission will be denied at execute step.") % entry.path))
+            end
             entry.removed = true
             entry.labeled = nil
             entry.show_bg
@@ -1381,11 +1384,23 @@ def execute
     while true
         dialog.run { |response|        
             if response == Gtk::Dialog::RESPONSE_OK
-                if toremove_amount > 0 && ! check_removal.active? && stuff['toremove'][:combo].active == 0
-                    show_popup(dialog, utf8(_("You have not confirmed that you noticed the permanent removal of the pictures marked for deletion.")))
-                    break
-                end
                 problem = false
+                if toremove_amount > 0 && stuff['toremove'][:combo].active == 0
+                    if ! check_removal.active?
+                        show_popup(dialog, utf8(_("You have not confirmed that you noticed the permanent removal of the pictures marked for deletion.")))
+                        problem = true
+                        break
+                    end
+                    $allentries.each { |entry|
+                        if entry.removed
+                            if ! FileTest.writable?(entry.path)
+                                show_popup(dialog, utf8(_("Sorry, permission denied to remove '%s'.") % [ entry.path ]))
+                                problem = true
+                                break
+                            end
+                        end
+                    }
+                end
                 label2entries = {}
                 $labels.values.each { |label| label2entries[label] = [] }
                 $allentries.each { |entry| entry.labeled and label2entries[entry.labeled] << entry }
@@ -1422,6 +1437,15 @@ def execute
                             rescue
                             end
                         }
+                        if stuff[key][:combo].active == 1
+                            label2entries[key].each { |entry|
+                                if ! FileTest.writable?(entry.path)
+                                    show_popup(dialog, utf8(_("Sorry, permission denied to move '%s'.") % [ entry.path ]))
+                                    problem = true
+                                    break
+                                end
+                            }
+                        end
                         if problem
                             break
                         end