Skip to content

Commit

Permalink
Remove leftover debug statements from fileserver (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfelsche authored Jan 10, 2025
1 parent 247b97c commit 41a59e0
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions jennet/fileserver.pony
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use "files"
use "http_server"
use "valbytes"
use "debug"

use @pony_os_errno[I32]()

class _FileServer is RequestHandler
let _filepath: FilePath
Expand Down Expand Up @@ -50,33 +48,19 @@ class _DirServer is RequestHandler

primitive _ReadFile
"""
Read a whole file into an `Array[U8] iso^` doing multiple calls to read in a loop.
Read a whole file into a `ByteArrays` instance doing multiple calls to read in a loop.
This is not optimally friendly to the whole runtime as it is hogging a scheduler thread doing blocking system calls.
"""
fun apply(path: FilePath): ByteArrays ? =>
Debug("Reading file " + path.path + " ...")
with file = OpenFile(path) as File do
file.clear_errno()
let file_size = file.size()

if file_size == -1 then
let err_str = match file.errno()
| FileError => "ERROR"
| FilePermissionDenied => "Permission denied"
| FileBadFileNumber => "Bad file number"
| FileEOF => "EOF"
| FileOK => "OK"
| FileExists => "EXISTS"
end
Debug("ERROR: " + @pony_os_errno().string() + " " + err_str)
error
end
Debug("file_size == " + if file_size == -1 then "-1" else file_size.string() end)
var bs = ByteArrays
var bytes_read = USize(0)
while bytes_read < file_size do
Debug("Reading " + (file_size - bytes_read).string() + " bytes from " + path.path)
let data = file.read(file_size - bytes_read)
bytes_read = bytes_read + data.size()
bs = bs + consume data
Expand Down

0 comments on commit 41a59e0

Please sign in to comment.