fix bug (sometimes filename is "Unknown")
This commit is contained in:
parent
8c89d4630f
commit
cd43d44d58
|
@ -25,23 +25,44 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isRequestWholeInfo = response.context.requestWholeInfo;
|
||||||
var taskList = response.data;
|
var taskList = response.data;
|
||||||
|
|
||||||
if (!ariaNgCommonService.extendArray(taskList, $rootScope.taskContext.list, 'gid')) {
|
if (isRequestWholeInfo) {
|
||||||
if (needRequestWholeInfo) {
|
|
||||||
$rootScope.taskContext.list = taskList;
|
$rootScope.taskContext.list = taskList;
|
||||||
needRequestWholeInfo = false;
|
needRequestWholeInfo = false;
|
||||||
|
} else {
|
||||||
|
if (ariaNgCommonService.extendArray(taskList, $rootScope.taskContext.list, 'gid')) {
|
||||||
|
needRequestWholeInfo = false;
|
||||||
} else {
|
} else {
|
||||||
needRequestWholeInfo = true;
|
needRequestWholeInfo = true;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
needRequestWholeInfo = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rootScope.taskContext.list) {
|
if ($rootScope.taskContext.list && $rootScope.taskContext.list.length > 0) {
|
||||||
aria2TaskService.processDownloadTasks($rootScope.taskContext.list);
|
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);
|
}, silent);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,8 @@
|
||||||
invokeContext.callback({
|
invokeContext.callback({
|
||||||
id: id,
|
id: id,
|
||||||
success: true,
|
success: true,
|
||||||
data: result
|
data: result,
|
||||||
|
context: invokeContext
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -118,7 +119,8 @@
|
||||||
id: id,
|
id: id,
|
||||||
success: false,
|
success: false,
|
||||||
data: error,
|
data: error,
|
||||||
errorProcessed: errorProcessed
|
errorProcessed: errorProcessed,
|
||||||
|
context: invokeContext
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
var getTaskName = function (task) {
|
var getTaskName = function (task) {
|
||||||
var taskName = "";
|
var taskName = "";
|
||||||
|
var success = true;
|
||||||
|
|
||||||
if (task.bittorrent && task.bittorrent.info) {
|
if (task.bittorrent && task.bittorrent.info) {
|
||||||
taskName = task.bittorrent.info.name;
|
taskName = task.bittorrent.info.name;
|
||||||
|
@ -41,9 +42,13 @@
|
||||||
|
|
||||||
if (!taskName) {
|
if (!taskName) {
|
||||||
taskName = $translate.instant('Unknown');
|
taskName = $translate.instant('Unknown');
|
||||||
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return taskName;
|
return {
|
||||||
|
name: taskName,
|
||||||
|
success: success
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var processDownloadTask = function (task) {
|
var processDownloadTask = function (task) {
|
||||||
|
@ -62,11 +67,13 @@
|
||||||
task.uploadSpeed = parseInt(task.uploadSpeed);
|
task.uploadSpeed = parseInt(task.uploadSpeed);
|
||||||
task.downloadSpeed = parseInt(task.downloadSpeed);
|
task.downloadSpeed = parseInt(task.downloadSpeed);
|
||||||
|
|
||||||
task.taskName = getTaskName(task);
|
|
||||||
task.idle = task.downloadSpeed == 0;
|
task.idle = task.downloadSpeed == 0;
|
||||||
|
|
||||||
task.remainTime = calculateDownloadRemainTime(task.remainLength, task.downloadSpeed);
|
task.remainTime = calculateDownloadRemainTime(task.remainLength, task.downloadSpeed);
|
||||||
|
|
||||||
|
var taskNameResult = getTaskName(task);
|
||||||
|
task.taskName = taskNameResult.name;
|
||||||
|
task.hasTaskName = taskNameResult.success;
|
||||||
|
|
||||||
if (task.files) {
|
if (task.files) {
|
||||||
for (var i = 0; i < task.files.length; i++) {
|
for (var i = 0; i < task.files.length; i++) {
|
||||||
var file = task.files[i];
|
var file = task.files[i];
|
||||||
|
@ -156,6 +163,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return invokeMethod({
|
return invokeMethod({
|
||||||
|
requestWholeInfo: full,
|
||||||
requestParams: full ? aria2RpcService.getFullTaskParams() : aria2RpcService.getBasicTaskParams(),
|
requestParams: full ? aria2RpcService.getFullTaskParams() : aria2RpcService.getBasicTaskParams(),
|
||||||
silent: !!silent,
|
silent: !!silent,
|
||||||
callback: function (response) {
|
callback: function (response) {
|
||||||
|
|
Reference in a new issue