We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cc3960d commit 5bcd0daCopy full SHA for 5bcd0da
fileloader/src/main/java/com/krishna/fileloader/network/FileDownloader.java
@@ -86,11 +86,11 @@ public File download(boolean autoRefresh) throws Exception {
86
87
//write the body to file
88
BufferedSink sink = Okio.buffer(Okio.sink(downloadFilePath));
89
- sink.writeAll(response.body().source());
+ long readBytes = sink.writeAll(response.body().source());
90
sink.close();
91
92
//check if downloaded file is not corrupt
93
- if (downloadFilePath.length() < response.body().contentLength()) {
+ if (readBytes < response.body().contentLength()) {
94
//delete the corrupt file
95
downloadFilePath.delete();
96
throw new IOException("Failed to download file: " + response);
0 commit comments