From e1a840a557f480f9e0e3bdaa71d648a509fef03e Mon Sep 17 00:00:00 2001 From: CN_SZTL Date: Fri, 6 Mar 2020 20:21:51 +0800 Subject: [PATCH] luci-app-unblockneteasemusic-go: fix fs --- .../luci-app-unblockneteasemusic-go/Makefile | 2 +- .../luasrc/model/cbi/unblockneteasemusic.lua | 25 +++++-------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/package/lean/luci-app-unblockneteasemusic-go/Makefile b/package/lean/luci-app-unblockneteasemusic-go/Makefile index 9f2c5ee040..60d6707f43 100644 --- a/package/lean/luci-app-unblockneteasemusic-go/Makefile +++ b/package/lean/luci-app-unblockneteasemusic-go/Makefile @@ -5,7 +5,7 @@ LUCI_TITLE:=LuCI support for UnblockNeteaseMusic Go LUCI_DEPENDS:=+bash +coreutils-nohup +curl +dnsmasq-full +openssl-util +ipset +UnblockNeteaseMusic-Go LUCI_PKGARCH:=all PKG_NAME:=luci-app-unblockneteasemusic-go -PKG_VERSION:=1.4 +PKG_VERSION:=1.5 PKG_RELEASE:=1 PKG_MAINTAINER:=https://github.com/cnsilvan/luci-app-unblockneteasemusic diff --git a/package/lean/luci-app-unblockneteasemusic-go/luasrc/model/cbi/unblockneteasemusic.lua b/package/lean/luci-app-unblockneteasemusic-go/luasrc/model/cbi/unblockneteasemusic.lua index e39dee33fb..aa42238409 100644 --- a/package/lean/luci-app-unblockneteasemusic-go/luasrc/model/cbi/unblockneteasemusic.lua +++ b/package/lean/luci-app-unblockneteasemusic-go/luasrc/model/cbi/unblockneteasemusic.lua @@ -1,4 +1,3 @@ -local fs = require "luci.fs" local http = luci.http mp = Map("unblockneteasemusic", translate("解除网易云音乐播放限制 (Golang)")) @@ -73,31 +72,19 @@ download.write = function() end function download_() - local sPath, sFile, fd, block - sPath = "/usr/share/UnblockNeteaseMusic/ca.crt" - sFile = nixio.fs.basename(sPath) - if luci.fs.isdirectory(sPath) then - fd = io.popen('tar -C "%s" -cz .' % {sPath}, "r") - sFile = sFile .. ".tar.gz" - else - fd = nixio.open(sPath, "r") - end - if not fd then - download.description = string.format('请在客户端信任该证书。该证书由你设备自动生成,安全可靠
%s', translate("Couldn't open file: ") .. sPath) - return - end - download.description = translate("请在客户端信任该证书。该证书由你设备自动生成,安全可靠") - http.header('Content-Disposition', 'attachment; filename="%s"' % {sFile}) + local sFile, block + sFile=nixio.open("/usr/share/UnblockNeteaseMusic/ca.crt","r") + http.header('Content-Disposition','attachment; filename="ca.crt"') http.prepare_content("application/octet-stream") while true do - block = fd:read(nixio.const.buffersize) - if (not block) or (#block ==0) then + block=sFile:read(nixio.const.buffersize) + if(not block)or(#block==0)then break else http.write(block) end end - fd:close() + sFile:close() http.close() end function delete_()