Merge pull request #1818 from dibdot/lxc_fix
[project/luci.git] / modules / luci-mod-failsafe / luasrc / controller / failsafe / failsafe.lua
index 5c62240..60caadb 100644 (file)
@@ -1,18 +1,7 @@
---[[
-LuCI - Lua Configuration Interface
-
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008-2011 Jo-Philipp Wich <xm@subsignal.org>
-Copyright 2012 Daniel Golle <dgolle@allnet.de>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-]]--
+-- Copyright 2008 Steven Barth <steven@midlink.org>
+-- Copyright 2008-2011 Jo-Philipp Wich <jow@openwrt.org>
+-- Copyright 2012 Daniel Golle <dgolle@allnet.de>
+-- Licensed to the public under the Apache License 2.0.
 
 module("luci.controller.failsafe.failsafe", package.seeall)
 
@@ -95,11 +84,13 @@ function action_flashops()
                                        fp = io.open(image_tmp, "w")
                                end
                        end
-                       if chunk then
-                               fp:write(chunk)
-                       end
-                       if eof then
-                               fp:close()
+                       if fp then
+                               if chunk then
+                                       fp:write(chunk)
+                               end
+                               if eof then
+                                       fp:close()
+                               end
                        end
                end
        )