From e270bd4b514c62d25bf637c186f4e3f8098fbd10 Mon Sep 17 00:00:00 2001 From: "mingguo.hu" Date: Mon, 6 Jun 2016 12:16:36 +0800 Subject: [PATCH] fix grif_file:find() offset sub error --- lib/resty/mongol/gridfs_file.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/resty/mongol/gridfs_file.lua b/lib/resty/mongol/gridfs_file.lua index 4a99e16..032b00c 100644 --- a/lib/resty/mongol/gridfs_file.lua +++ b/lib/resty/mongol/gridfs_file.lua @@ -157,7 +157,7 @@ function gridfs_file_mt:read(size, offset) r = self.chunk_col:find_one({files_id = self.files_id, n = n}) if not r then return nil, "read chunk failed" end if size - rn < self.chunk_size then - bytes = bytes .. string.sub(r.data, 1, size - rn) + bytes = bytes .. string.sub(r.data, offset + 1, offset + size - rn) rn = size else bytes = bytes .. r.data