librelist archives

« back to archive

[bamboo]上传bug

[bamboo]上传bug

From:
Uno Young
Date:
2012-04-23 @ 03:09
在models/upload.lua中

batch = function (self, req, params, dest_dir, prefix, postfix, rename_func)
I_AM_CLASS(self)
local file_objs = List()
-- file data are stored as arraies in params
for i, v in ipairs(params) do
local name, path = savefile { req = req, file_obj = v, dest_dir = dest_dir,
prefix = prefix, postfix = postfix, rename_func = rename_func }
if not path or not name then return nil end
-- create file instance
local file_instance = self { name = name, path = path }
if file_instance then
-- store to db
-- file_instance:save()
-- fix the id sequence
>>>>> file_instance.id = file_instance.id + i - 1
file_objs:append(file_instance)
end
end

因为现在是save之后才有Id,所以这儿会出错

Re: [bamboo]上传bug

From:
道哥
Date:
2012-04-28 @ 06:25
把这句注释掉就对了吧。

在 2012-04-23 11:09:20,"Uno Young" <littlehaker@gmail.com> 写道:
在models/upload.lua中


batch = function (self, req, params, dest_dir, prefix, postfix, rename_func)
I_AM_CLASS(self)
local file_objs = List()
-- file data are stored as arraies in params
for i, v in ipairs(params) do
local name, path = savefile { req = req, file_obj = v, dest_dir = 
dest_dir, prefix = prefix, postfix = postfix, rename_func = rename_func }
if not path or not name then return nil end
-- create file instance
local file_instance = self { name = name, path = path }
if file_instance then
-- store to db
-- file_instance:save()
-- fix the id sequence
>>>>>file_instance.id = file_instance.id + i - 1
file_objs:append(file_instance)
end
end


因为现在是save之后才有Id,所以这儿会出错