Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in Res:sendFile() #10

Open
DTJF opened this issue Aug 5, 2020 · 0 comments
Open

Issue in Res:sendFile() #10

DTJF opened this issue Aug 5, 2020 · 0 comments

Comments

@DTJF
Copy link

DTJF commented Aug 5, 2020

I've an issue in function Res:sendFile() in the local function doSend(): When the file length is a multiple of 512 (1024, 1536, 2048, ...) the function fails at the end of the file, since buf is nil in self._skt:send(buf). Here's how I fixed it:

  print('* Sending ', filename)
  local pos, fin = 0, nil
  local function doSend()
    file.open(filename, 'r')
    if file.seek('set', pos) == nil then
      fin = 1
    else
      local buf = file.read(512)
      pos = pos + 512
      if buf == nil then
        fin = 1
      else
        self._skt:send(buf)
      end
    end
    file.close()
    if fin then
      self:close()
      print('* Finished ', filename)
    end
  end

Great project, thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant