{"action":"opened","issue":{"url":"https://api.github.com/repos/tonyofrancis/Fetch/issues/35","repository_url":"https://api.github.com/repos/tonyofrancis/Fetch","labels_url":"https://api.github.com/repos/tonyofrancis/Fetch/issues/35/labels{/name}","comments_url":"https://api.github.com/repos/tonyofrancis/Fetch/issues/35/comments","events_url":"https://api.github.com/repos/tonyofrancis/Fetch/issues/35/events","html_url":"https://github.com/tonyofrancis/Fetch/issues/35","id":226206418,"number":35,"title":"Wrong progress when downloading big files (Tested with 4.2 GB file)","user":{"login":"ioltean","id":8298910,"avatar_url":"https://avatars0.githubusercontent.com/u/8298910?v=3","gravatar_id":"","url":"https://api.github.com/users/ioltean","html_url":"https://github.com/ioltean","followers_url":"https://api.github.com/users/ioltean/followers","following_url":"https://api.github.com/users/ioltean/following{/other_user}","gists_url":"https://api.github.com/users/ioltean/gists{/gist_id}","starred_url":"https://api.github.com/users/ioltean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ioltean/subscriptions","organizations_url":"https://api.github.com/users/ioltean/orgs","repos_url":"https://api.github.com/users/ioltean/repos","events_url":"https://api.github.com/users/ioltean/events{/privacy}","received_events_url":"https://api.github.com/users/ioltean/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-05-04T08:14:06Z","updated_at":"2017-05-04T08:14:06Z","closed_at":null,"body":"httpURLConnection.getContentLenght() is not working correct when the file is bigger than the Integer.MAX_VALUE. In this case it will return -1 and I guess that's why the progress you return will always be 0%.\r\n\r\nAn option to fix this issue would be to get the content length directly from the headers and convert it to long:\r\n\r\nLong.valueOf(connection.getHeaderField(\"Content-Length\"))\r\n\r\ninstead of:\r\n\r\nprivate void setContentLength() {\r\n        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {\r\n            fileSize = downloadedBytes + httpURLConnection.getContentLengthLong();\r\n        } else {\r\n            fileSize = downloadedBytes + httpURLConnection.getContentLength();\r\n        }\r\n    }"}}
{"actor":{"display_login":"ioltean"}}