{"action":"created","issue":{"url":"https://api.github.com/repos/ocsigen/lwt/issues/265","repository_url":"https://api.github.com/repos/ocsigen/lwt","labels_url":"https://api.github.com/repos/ocsigen/lwt/issues/265/labels{/name}","comments_url":"https://api.github.com/repos/ocsigen/lwt/issues/265/comments","events_url":"https://api.github.com/repos/ocsigen/lwt/issues/265/events","html_url":"https://github.com/ocsigen/lwt/issues/265","id":165160289,"number":265,"title":"\"Lwt_unix.files_of_directory dir\" fails if \"dir\" can't be read","user":{"login":"hcarty","id":199147,"avatar_url":"https://avatars.githubusercontent.com/u/199147?v=3","gravatar_id":"","url":"https://api.github.com/users/hcarty","html_url":"https://github.com/hcarty","followers_url":"https://api.github.com/users/hcarty/followers","following_url":"https://api.github.com/users/hcarty/following{/other_user}","gists_url":"https://api.github.com/users/hcarty/gists{/gist_id}","starred_url":"https://api.github.com/users/hcarty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hcarty/subscriptions","organizations_url":"https://api.github.com/users/hcarty/orgs","repos_url":"https://api.github.com/users/hcarty/repos","events_url":"https://api.github.com/users/hcarty/events{/privacy}","received_events_url":"https://api.github.com/users/hcarty/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/ocsigen/lwt/milestones/2","html_url":"https://github.com/ocsigen/lwt/milestones/Lwt_stream","labels_url":"https://api.github.com/repos/ocsigen/lwt/milestones/2/labels","id":1855505,"number":2,"title":"Lwt_stream","description":"Work out issues with Lwt_stream to the greatest extent possible subject to retaining backwards compatibility.","creator":{"login":"aantron","id":12073668,"avatar_url":"https://avatars.githubusercontent.com/u/12073668?v=3","gravatar_id":"","url":"https://api.github.com/users/aantron","html_url":"https://github.com/aantron","followers_url":"https://api.github.com/users/aantron/followers","following_url":"https://api.github.com/users/aantron/following{/other_user}","gists_url":"https://api.github.com/users/aantron/gists{/gist_id}","starred_url":"https://api.github.com/users/aantron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aantron/subscriptions","organizations_url":"https://api.github.com/users/aantron/orgs","repos_url":"https://api.github.com/users/aantron/repos","events_url":"https://api.github.com/users/aantron/events{/privacy}","received_events_url":"https://api.github.com/users/aantron/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":2,"state":"open","created_at":"2016-06-29T16:16:51Z","updated_at":"2016-12-05T20:47:16Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2016-07-12T19:29:07Z","updated_at":"2016-12-05T20:47:16Z","closed_at":"2016-12-05T20:47:16Z","body":"I'm not sure how to handle this kind of failure in Lwt's current state (2.5.2) since it happens in the generation of the stream, presumably on https://github.com/ocsigen/lwt/blob/7ff98087ad9dfb447aee4e41c282b57f48787f9a/src/unix/lwt_unix.ml#L1078\n\nOne change would be to open the directory before returning the stream, changing the type to:\n\n``` ocaml\nval files_of_directory : string -> string Lwt_stream.t Lwt.t\n```\n\nor add a new function with the new signature.\n\nExample of the failure from utop:\n\n``` ocaml\n#require \"lwt.unix\";;\n# Lwt_unix.files_of_directory \"/doesnotexist\";;\n- : bytes Lwt_stream.t = <abstr>\n# Lwt_unix.files_of_directory \"/root\" |> Lwt_stream.iter_s Lwt_io.printl;;\nException: Unix.Unix_error (Unix.ENOENT, \"opendir\", \"/root\").\n```\n"},"comment":{"url":"https://api.github.com/repos/ocsigen/lwt/issues/comments/264972205","html_url":"https://github.com/ocsigen/lwt/issues/265#issuecomment-264972205","issue_url":"https://api.github.com/repos/ocsigen/lwt/issues/265","id":264972205,"user":{"login":"aantron","id":12073668,"avatar_url":"https://avatars.githubusercontent.com/u/12073668?v=3","gravatar_id":"","url":"https://api.github.com/users/aantron","html_url":"https://github.com/aantron","followers_url":"https://api.github.com/users/aantron/followers","following_url":"https://api.github.com/users/aantron/following{/other_user}","gists_url":"https://api.github.com/users/aantron/gists{/gist_id}","starred_url":"https://api.github.com/users/aantron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aantron/subscriptions","organizations_url":"https://api.github.com/users/aantron/orgs","repos_url":"https://api.github.com/users/aantron/repos","events_url":"https://api.github.com/users/aantron/events{/privacy}","received_events_url":"https://api.github.com/users/aantron/received_events","type":"User","site_admin":false},"created_at":"2016-12-05T20:47:16Z","updated_at":"2016-12-05T20:47:16Z","body":"Closing this issue as there is a fairly reasonable solution. For current Lwt, in the above code, `Lwt_stream.Value` should be `Result.Ok`, and `Lwt_stream.Error` should be `Result.Error`. This issue is linked from #250, for the future `Lwt_stream` work.\r\n\r\nAlso, `files_of_directory` may itself eventually be deprecated (see #292)."}}
{"actor":{"display_login":"aantron"}}