Delete files with too less bytes.

This commit is contained in:
Fabian Schlenz 2016-07-04 09:35:40 +02:00
parent 45e3e22ef3
commit 293e77636e
1 changed files with 2 additions and 1 deletions

View File

@ -275,11 +275,12 @@ class DownloadManager {
fos.write(response.getBytes().getData());
try { Thread.sleep(Config.DELAY_AFTER_GET_FILE); } catch(InterruptedException e) {}
} while(offset < size && response.getBytes().getData().length>0);
fos.close();
if (offset < size) {
System.out.println("Requested file " + target + " with " + size + " bytes, but got only " + offset + " bytes.");
new File(target).delete();
System.exit(1);
}
fos.close();
return true;
} catch (java.io.IOException ex) {
if (fos!=null) fos.close();