modules/luci-mod-failsafe: Fix nil file descriptor error
[project/luci.git] / modules / luci-mod-failsafe / luasrc / controller / failsafe / failsafe.lua
index 6f78643..60caadb 100644 (file)
@@ -84,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
        )