修复组合任务初始化失败时,无法删除的问题
修复`reStart()`后,无法停止的问题 ftp增加主动模式,开启主动模式:https://aria.laoyuyu.me/aria_doc/api/ftp_params.html 优化提示
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.aria.core.common;
|
||||
|
||||
/**
|
||||
* FTP 连接模式
|
||||
*/
|
||||
public interface FtpConnectionMode {
|
||||
/**
|
||||
* 被动模式
|
||||
*/
|
||||
int DATA_CONNECTION_MODE_PASV = 0;
|
||||
/**
|
||||
* 主动模式
|
||||
*/
|
||||
int DATA_CONNECTION_MODE_ACTIVITY = 1;
|
||||
}
|
||||
@@ -73,6 +73,7 @@ public class RecordHandler implements IRecordHandler {
|
||||
mAdapter.onPre();
|
||||
mTaskRecord = DbDataHelper.getTaskRecord(getFilePath());
|
||||
if (mTaskRecord == null) {
|
||||
FileUtil.createFile(getFilePath());
|
||||
initRecord(true);
|
||||
} else {
|
||||
File file = new File(mTaskRecord.filePath);
|
||||
|
||||
@@ -23,7 +23,10 @@ import com.arialyy.aria.core.inf.IRecordHandler;
|
||||
import com.arialyy.aria.core.upload.UploadEntity;
|
||||
import com.arialyy.aria.orm.DbEntity;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Created by Lyy on 2016/9/23.
|
||||
@@ -32,6 +35,44 @@ import java.util.List;
|
||||
public class CheckUtil {
|
||||
private static final String TAG = "CheckUtil";
|
||||
|
||||
/**
|
||||
* 检查ip是否正确
|
||||
*
|
||||
* @param ip ipv4 地址
|
||||
* @return {@code true} ip 正确,{@code false} ip 错误
|
||||
*/
|
||||
public static boolean checkIp(String ip) {
|
||||
if (TextUtils.isEmpty(ip) || ip.length() < 7 || ip.length() > 15) {
|
||||
return false;
|
||||
}
|
||||
Pattern p = Pattern.compile(Regular.REG_IP_V4);
|
||||
Matcher m = p.matcher(ip);
|
||||
return m.find() && m.groupCount() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断http请求是否有效
|
||||
* {@link HttpURLConnection#HTTP_BAD_GATEWAY} or {@link HttpURLConnection#HTTP_BAD_METHOD}
|
||||
* or {@link HttpURLConnection#HTTP_BAD_REQUEST} 无法重试
|
||||
*
|
||||
* @param errorCode http 返回码
|
||||
* @return {@code true} 无效请求;{@code false} 有效请求
|
||||
*/
|
||||
public static boolean httpIsBadRequest(int errorCode) {
|
||||
return errorCode == HttpURLConnection.HTTP_BAD_GATEWAY
|
||||
|| errorCode == HttpURLConnection.HTTP_BAD_METHOD
|
||||
|| errorCode == HttpURLConnection.HTTP_BAD_REQUEST;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断ftp请求是否有效
|
||||
*
|
||||
* @return {@code true} 无效请求;{@code false} 有效请求
|
||||
*/
|
||||
public static boolean ftpIsBadRequest(int errorCode) {
|
||||
return errorCode >= 400 && errorCode < 600;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查和处理下载任务的路径冲突
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user