fix: FileDownloadTask does not fail if 404.

This commit is contained in:
huanghongxun
2021-09-18 23:26:37 +08:00
parent 28cc7c0700
commit ea9f547ada
2 changed files with 11 additions and 1 deletions

View File

@@ -27,6 +27,7 @@ import org.jackhuang.hmcl.util.io.NetworkUtils;
import org.jackhuang.hmcl.util.io.ResponseCodeException;
import java.io.Closeable;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
@@ -117,7 +118,7 @@ public abstract class FetchTask<T> extends Task<T> {
continue;
}
} else if (responseCode / 100 == 4) {
break; // we will not try this URL again
throw new FileNotFoundException();
} else if (responseCode / 100 != 2) {
throw new ResponseCodeException(url, responseCode);
}
@@ -157,6 +158,12 @@ public abstract class FetchTask<T> extends Task<T> {
}
return;
} catch (FileNotFoundException ex) {
failedURL = url;
exception = ex;
Logging.LOG.log(Level.WARNING, "Failed to download " + url + ", not found", ex);
break; // we will not try this URL again
} catch (IOException ex) {
failedURL = url;
exception = ex;