1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-11-20 02:18:20 +01:00

fallback to sendfile if move file fail in upload

This commit is contained in:
DanyLE 2022-08-22 23:04:44 +02:00
parent aec0ae5bb7
commit 4d091604d1
2 changed files with 10 additions and 3 deletions

View File

@ -186,7 +186,7 @@ end
function VFSController:upload(...) function VFSController:upload(...)
auth_or_die("User unauthorized. Please login") auth_or_die("User unauthorized. Please login")
local vfs = require("vfs") local vfs = require("vfs")
if REQUEST then if REQUEST and REQUEST.path then
local r, m = require("vfs").upload(REQUEST.path) local r, m = require("vfs").upload(REQUEST.path)
if r then if r then
result(r) result(r)
@ -195,7 +195,7 @@ function VFSController:upload(...)
fail(m) fail(m)
end end
else else
fail("Query not found") fail("Invalid query")
end end
return false return false
end end

View File

@ -150,7 +150,14 @@ vfs.upload = function(path)
local index = 0 local index = 0
while(REQUEST["upload-"..index..".tmp"] ~= nil) do while(REQUEST["upload-"..index..".tmp"] ~= nil) do
local file = m.."/"..REQUEST["upload-"..index..".file"] local file = m.."/"..REQUEST["upload-"..index..".file"]
ulib.move(REQUEST["upload-"..index..".tmp"], file) local ret = ulib.move(REQUEST["upload-"..index..".tmp"], file)
if not ret then
print("USEEEEEEEEEEE SENDDDDDDDDDDDDDDDDDFILE")
local ret = ulib.send_file(REQUEST["upload-"..index..".tmp"], file)
end
if not ret then
return false, "Unable to copy file"
end
ulib.chown(file, uid.id, uid.gid) ulib.chown(file, uid.id, uid.gid)
index = index + 1 index = index + 1
end end