fix bug fix bug https://github.com/AriaLyy/Aria/issues/595
修复一个数据升级导致的taskType列不存在问题,https://github.com/AriaLyy/Aria/issues/586
This commit is contained in:
@@ -51,9 +51,6 @@ public abstract class AbsNormalEntity extends AbsEntity implements Parcelable {
|
||||
*/
|
||||
private int taskType;
|
||||
|
||||
@Override public int getTaskType() {
|
||||
return taskType;
|
||||
}
|
||||
|
||||
public void setTaskType(int taskType) {
|
||||
this.taskType = taskType;
|
||||
|
||||
@@ -78,22 +78,26 @@ public class DownloadEntity extends AbsNormalEntity implements Parcelable {
|
||||
return getUrl();
|
||||
}
|
||||
|
||||
//@Override public int getTaskType() {
|
||||
// int type;
|
||||
// if (TextUtils.isEmpty(getUrl())) {
|
||||
// type = ITaskWrapper.ERROR;
|
||||
// } else if (getUrl().startsWith("ftp")) {
|
||||
// type = ITaskWrapper.D_FTP;
|
||||
// } else {
|
||||
// M3U8Entity temp = getM3U8Entity();
|
||||
// if (temp == null) {
|
||||
// type = ITaskWrapper.D_HTTP;
|
||||
// } else {
|
||||
// type = temp.isLive() ? ITaskWrapper.M3U8_LIVE : ITaskWrapper.M3U8_VOD;
|
||||
// }
|
||||
// }
|
||||
// return type;
|
||||
//}
|
||||
@Override public int getTaskType() {
|
||||
int type;
|
||||
if (TextUtils.isEmpty(getUrl())) {
|
||||
type = ITaskWrapper.ERROR;
|
||||
} else if (getUrl().startsWith("http")) {
|
||||
type = ITaskWrapper.D_HTTP;
|
||||
} else if (getUrl().startsWith("ftp")) {
|
||||
type = ITaskWrapper.D_FTP;
|
||||
} else if (getUrl().startsWith("sftp")) {
|
||||
type = ITaskWrapper.D_SFTP;
|
||||
} else {
|
||||
M3U8Entity temp = getM3U8Entity();
|
||||
if (temp == null) {
|
||||
type = ITaskWrapper.D_HTTP;
|
||||
} else {
|
||||
type = temp.isLive() ? ITaskWrapper.M3U8_LIVE : ITaskWrapper.M3U8_VOD;
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public DownloadEntity() {
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.arialyy.aria.core.loader.ILoaderVisitor;
|
||||
import com.arialyy.aria.core.loader.IRecordHandler;
|
||||
import com.arialyy.aria.core.loader.IThreadTaskBuilder;
|
||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import java.io.File;
|
||||
@@ -253,8 +254,8 @@ public abstract class AbsGroupLoader implements ILoaderVisitor, ILoader {
|
||||
mListener.onComplete();
|
||||
return;
|
||||
}
|
||||
handlerTask(looper);
|
||||
startTimer();
|
||||
handlerTask(looper);
|
||||
Looper.loop();
|
||||
}
|
||||
|
||||
@@ -320,6 +321,11 @@ public abstract class AbsGroupLoader implements ILoaderVisitor, ILoader {
|
||||
}
|
||||
}
|
||||
|
||||
protected void fail(BaseException e, boolean needRetry){
|
||||
closeTimer();
|
||||
getListener().onFail(needRetry, e);
|
||||
}
|
||||
|
||||
@Override public long getCurrentProgress() {
|
||||
return mCurrentLocation;
|
||||
}
|
||||
|
||||
@@ -99,8 +99,6 @@ public abstract class AbsGroupLoaderUtil implements IUtil {
|
||||
}
|
||||
|
||||
buildLoaderStructure();
|
||||
// MsgEvent 已经是在线程中使用了,不需要重开线程
|
||||
mLoader.run();
|
||||
//new Thread(mLoader).start();
|
||||
new Thread(mLoader).start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ public interface IThreadStateManager extends ILoaderComponent {
|
||||
|
||||
/**
|
||||
* 更新当前进度
|
||||
*
|
||||
* @param currentProgress 当前进度
|
||||
*/
|
||||
void updateCurrentProgress(long currentProgress);
|
||||
|
||||
@@ -115,10 +115,7 @@ public abstract class AbsNormalLoaderUtil implements IUtil {
|
||||
//}
|
||||
|
||||
BuildLoaderStructure();
|
||||
// MsgEvent 已经是在线程中使用了,不需要重开线程
|
||||
mLoader.run();
|
||||
//new Thread(mLoader).start();
|
||||
|
||||
new Thread(mLoader).start();
|
||||
onStart();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@ package com.arialyy.aria.core.upload;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
import com.arialyy.aria.core.common.AbsNormalEntity;
|
||||
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
||||
import com.arialyy.aria.orm.annotation.Primary;
|
||||
|
||||
/**
|
||||
@@ -56,12 +58,12 @@ public class UploadEntity extends AbsNormalEntity implements Parcelable {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
//@Override public int getTaskType() {
|
||||
// if (TextUtils.isEmpty(getUrl())){
|
||||
// return ITaskWrapper.ERROR;
|
||||
// }
|
||||
// return getUrl().startsWith("ftp") ? ITaskWrapper.U_FTP : ITaskWrapper.U_HTTP;
|
||||
//}
|
||||
@Override public int getTaskType() {
|
||||
if (TextUtils.isEmpty(getUrl())) {
|
||||
return ITaskWrapper.ERROR;
|
||||
}
|
||||
return getUrl().startsWith("ftp") ? ITaskWrapper.U_FTP : ITaskWrapper.U_HTTP;
|
||||
}
|
||||
|
||||
public UploadEntity() {
|
||||
}
|
||||
|
||||
@@ -182,14 +182,14 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
// ----------- 2、为防止字段增加失败的情况,先给旧表增加字段
|
||||
List<String> newAddColum = getNewColumn(newTabColumns, oldTabColumns);
|
||||
// 删除重命名的字段
|
||||
Map<String, String > modifyMap = null;
|
||||
if (modifyColumns != null){
|
||||
Map<String, String> modifyMap = null;
|
||||
if (modifyColumns != null) {
|
||||
modifyMap = modifyColumns.get(tableName);
|
||||
if (modifyMap != null){
|
||||
if (modifyMap != null) {
|
||||
Iterator<String> it = newAddColum.iterator();
|
||||
while (it.hasNext()){
|
||||
while (it.hasNext()) {
|
||||
String s = it.next();
|
||||
if (modifyMap.get(s) != null){
|
||||
if (modifyMap.get(s) != null) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
@@ -197,10 +197,11 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
// 给旧表增加字段,防止新增字段失败
|
||||
if (newAddColum.size() > 0){
|
||||
if (newAddColum.size() > 0) {
|
||||
String sql = "ALTER TABLE %s ADD COLUMN %s %s";
|
||||
for (String nc : newAddColum){
|
||||
String temp = String.format(sql, tableName, nc, SqlUtil.getColumnTypeByFieldName(clazz, nc));
|
||||
for (String nc : newAddColum) {
|
||||
String temp =
|
||||
String.format(sql, tableName, nc, SqlUtil.getColumnTypeByFieldName(clazz, nc));
|
||||
ALog.d(TAG, "添加表字段的sql:" + temp);
|
||||
db.execSQL(temp);
|
||||
}
|
||||
@@ -234,7 +235,8 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
|
||||
for (String column : oldTabColumns) {
|
||||
if (!diffTab.isEmpty() && diffTab.contains(column)
|
||||
&& (modifyMap != null && !modifyMap.containsKey(column))) { // 如果旧表字段有修改,忽略这个删除
|
||||
// 如果旧表字段有修改,忽略这个删除
|
||||
&& !(modifyMap != null && modifyMap.containsKey(column))) {
|
||||
continue;
|
||||
}
|
||||
params.append(column).append(",");
|
||||
|
||||
Reference in New Issue
Block a user