> @@ -701,14 +702,11 @@ public void downloadBlob(String container, String name,
> File destination, Execut
> Futures.getUnchecked(Futures.allAsList(results));
>
> } catch (IOException e) {
> - // cleanup, attempt to delete large file
> - if (raf != null) {
> - try {
> - raf.close();
> - } catch (IOException e1) {}
> - }
> + Closeables2.closeQuietly(raf);
You can do what @nacx suggests with slightly more complicated resource
management:
```java
RandomAccessFile raf = null;
File tmpFile = null;
try {
tempFile = new File(...);
raf = new RandomAccessFile(tempFile);
raf.write(...);
raf.close();
raf = null;
tempFile.renameTo(destinationFile);
tempFile = null;
} finally {
Closeables2.closeQuietly(raf);
if (tempFile != null) {
tempFile.delete();
}
}
```
This ensures that `destinationFile` is not overwritten unless the download
succeeds.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1007/files/0003721c3e983e3f3c08824d86cbc7e5098f4eb4#r78420532