Browse Source

Merge pull request #120 from litnimax/master

Fix for  #119.
Peter Justin 10 years ago
parent
commit
87799ac9b1
1 changed files with 16 additions and 10 deletions
  1. 16 10
      flaskbb/management/views.py

+ 16 - 10
flaskbb/management/views.py

@@ -479,13 +479,18 @@ def enable_plugin(plugin):
 
         disabled_file = os.path.join(plugin_dir, "DISABLED")
 
-        os.remove(disabled_file)
-
-        flash(_("Plugin is enabled. Please reload your app."), "success")
-
-        flash(_("If you are using a host which doesn't support writting on the "
+        try:
+            if os.path.exists(disabled_file):
+                os.remove(disabled_file)
+                flash(_("Plugin is enabled. Please reload your app."), "success")
+            else:
+                flash(_("Plugin is already enabled. Please reload  your app."), "warning")
+
+        except OSError:
+            flash(_("If you are using a host which doesn't support writting on the "
                 "disk, this won't work - than you need to delete the "
-                "'DISABLED' file by yourself."), "info")
+                "'DISABLED' file by yourself."), "danger")
+
     else:
         flash(_("Couldn't enable Plugin."), "danger")
 
@@ -508,11 +513,12 @@ def disable_plugin(plugin):
 
     disabled_file = os.path.join(plugin_dir, "DISABLED")
 
-    open(disabled_file, "a").close()
-
-    flash(_("Plugin is disabled. Please reload your app."), "success")
+    try:
+        open(disabled_file, "a").close()
+        flash(_("Plugin is disabled. Please reload your app."), "success")
 
-    flash(_("If you are using a host which doesn't "
+    except OSError:
+        flash(_("If you are using a host which doesn't "
             "support writting on the disk, this won't work - than you need to "
             "create a 'DISABLED' file by yourself."), "info")