luci-app-unblockneteasemusic-go: fix fs
This commit is contained in:
parent
3be2daa0b3
commit
e1a840a557
@ -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
|
||||
|
||||
@ -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('请在客户端信任该证书。该证书由你设备自动生成,安全可靠<br/><span style="color: red">%s</span>', 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_()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user