fix bug (sometimes filename is "Unknown")

This commit is contained in:
MaysWind 2016-06-23 00:39:44 +08:00
parent 8c89d4630f
commit cd43d44d58
3 changed files with 43 additions and 12 deletions

View file

@ -25,23 +25,44 @@
return;
}
var isRequestWholeInfo = response.context.requestWholeInfo;
var taskList = response.data;
if (!ariaNgCommonService.extendArray(taskList, $rootScope.taskContext.list, 'gid')) {
if (needRequestWholeInfo) {
if (isRequestWholeInfo) {
$rootScope.taskContext.list = taskList;
needRequestWholeInfo = false;
} else {
if (ariaNgCommonService.extendArray(taskList, $rootScope.taskContext.list, 'gid')) {
needRequestWholeInfo = false;
} else {
needRequestWholeInfo = true;
}
} else {
needRequestWholeInfo = false;
}
if ($rootScope.taskContext.list) {
if ($rootScope.taskContext.list && $rootScope.taskContext.list.length > 0) {
aria2TaskService.processDownloadTasks($rootScope.taskContext.list);
$rootScope.taskContext.enableSelectAll = $rootScope.taskContext.list.length > 0;
if (!isRequestWholeInfo) {
var hasFullStruct = false;
for (var i = 0; i < $rootScope.taskContext.list.length; i++) {
var task = $rootScope.taskContext.list[i];
if (task.hasTaskName || task.files || task.bittorrent) {
hasFullStruct = true;
break;
}
}
if (!hasFullStruct) {
needRequestWholeInfo = true;
$rootScope.taskContext.list.length = 0;
return;
}
}
}
$rootScope.taskContext.enableSelectAll = $rootScope.taskContext.list && $rootScope.taskContext.list.length > 0;
}, silent);
};

View file

@ -101,7 +101,8 @@
invokeContext.callback({
id: id,
success: true,
data: result
data: result,
context: invokeContext
});
}
};
@ -118,7 +119,8 @@
id: id,
success: false,
data: error,
errorProcessed: errorProcessed
errorProcessed: errorProcessed,
context: invokeContext
});
}
};

View file

@ -26,6 +26,7 @@
var getTaskName = function (task) {
var taskName = "";
var success = true;
if (task.bittorrent && task.bittorrent.info) {
taskName = task.bittorrent.info.name;
@ -41,9 +42,13 @@
if (!taskName) {
taskName = $translate.instant('Unknown');
success = false;
}
return taskName;
return {
name: taskName,
success: success
};
};
var processDownloadTask = function (task) {
@ -62,11 +67,13 @@
task.uploadSpeed = parseInt(task.uploadSpeed);
task.downloadSpeed = parseInt(task.downloadSpeed);
task.taskName = getTaskName(task);
task.idle = task.downloadSpeed == 0;
task.remainTime = calculateDownloadRemainTime(task.remainLength, task.downloadSpeed);
var taskNameResult = getTaskName(task);
task.taskName = taskNameResult.name;
task.hasTaskName = taskNameResult.success;
if (task.files) {
for (var i = 0; i < task.files.length; i++) {
var file = task.files[i];
@ -156,6 +163,7 @@
}
return invokeMethod({
requestWholeInfo: full,
requestParams: full ? aria2RpcService.getFullTaskParams() : aria2RpcService.getBasicTaskParams(),
silent: !!silent,
callback: function (response) {