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

This commit is contained in:
Frederic Bregier 2014-01-20 16:47:09 +01:00 committed by Trustin Lee
parent 743c035ebb
commit b037eda614

View File

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