Fix try to delete file while it does not exist anymore (see #2102 and #1713) in reference to this issue

This commit is contained in:
Frederic Bregier 2014-01-20 16:43:55 +01:00 committed by Trustin Lee
parent ed8ee33661
commit da5da8e212

View File

@ -226,9 +226,10 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
@Override
public void delete() {
if (! isRenamed) {
if (file != null) {
if (file != null && file.exists()) {
file.delete();
}
file = null;
}
}
@ -308,6 +309,9 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
if (dest == null) {
throw new NullPointerException("dest");
}
if (file == null) {
throw new IOException("No file defined so cannot be renamed");
}
if (!file.renameTo(dest)) {
// must copy
FileInputStream inputStream = new FileInputStream(file);