Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
mycard
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
syntax_j
mycard
Commits
97fd7c71
Commit
97fd7c71
authored
Dec 09, 2016
by
wudizhanche1000
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: 下载不能正确报错
parent
74fd12cf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
33 deletions
+46
-33
app/app-detail.component.html
app/app-detail.component.html
+1
-1
app/apps.service.ts
app/apps.service.ts
+11
-7
app/download.service.ts
app/download.service.ts
+34
-25
No files found.
app/app-detail.component.html
View file @
97fd7c71
...
@@ -66,7 +66,7 @@
...
@@ -66,7 +66,7 @@
<td
*ngIf=
"!mod.isInstalled()"
>
<td
*ngIf=
"!mod.isInstalled()"
>
<button
i18n
(click)=
"installMod(mod)"
type=
"button"
*ngIf=
"!mod.isInstalled()"
class=
"btn btn-primary btn-sm"
>
安装
</button>
<button
i18n
(click)=
"installMod(mod)"
type=
"button"
*ngIf=
"!mod.isInstalled()"
class=
"btn btn-primary btn-sm"
>
安装
</button>
</td>
</td>
<td
*ngIf=
"mod.isInstalled()&&!mod.isReady()"
>
:
<td
*ngIf=
"mod.isInstalled()&&!mod.isReady()"
>
<progress
class=
"progress progress-striped progress-animated"
value=
"{{mod.status.progress}}"
max=
"{{mod.status.total}}"
></progress>
<progress
class=
"progress progress-striped progress-animated"
value=
"{{mod.status.progress}}"
max=
"{{mod.status.total}}"
></progress>
<!--<div i18n *ngIf="mod.isWaiting()">等待安装...</div>-->
<!--<div i18n *ngIf="mod.isWaiting()">等待安装...</div>-->
</td>
</td>
...
...
app/apps.service.ts
View file @
97fd7c71
...
@@ -400,7 +400,7 @@ export class AppsService {
...
@@ -400,7 +400,7 @@ export class AppsService {
app
.
status
.
status
=
"
ready
"
;
app
.
status
.
status
=
"
ready
"
;
Logger
.
info
(
"
Update Finished:
"
,
app
);
Logger
.
info
(
"
Update Finished:
"
,
app
);
}
catch
(
e
)
{
}
catch
(
e
)
{
Logger
.
error
(
"
Update Failed:
"
,
e
);
Logger
.
error
(
"
Update Failed:
"
,
e
);
app
.
status
.
status
=
"
ready
"
;
app
.
status
.
status
=
"
ready
"
;
}
}
}
}
...
@@ -472,12 +472,16 @@ export class AppsService {
...
@@ -472,12 +472,16 @@ export class AppsService {
app
.
status
.
status
=
"
downloading
"
;
app
.
status
.
status
=
"
downloading
"
;
let
metalink
=
await
this
.
http
.
get
(
metalinkUrl
).
map
((
response
)
=>
response
.
text
()).
toPromise
();
let
metalink
=
await
this
.
http
.
get
(
metalinkUrl
).
map
((
response
)
=>
response
.
text
()).
toPromise
();
let
downloadId
=
await
this
.
downloadService
.
addMetalink
(
metalink
,
dir
);
let
downloadId
=
await
this
.
downloadService
.
addMetalink
(
metalink
,
dir
);
await
this
.
downloadService
.
progress
(
downloadId
,
(
status
:
DownloadStatus
)
=>
{
try
{
app
.
status
.
progress
=
status
.
completedLength
;
await
this
.
downloadService
.
progress
(
downloadId
,
(
status
:
DownloadStatus
)
=>
{
app
.
status
.
total
=
status
.
totalLength
;
app
.
status
.
progress
=
status
.
completedLength
;
app
.
status
.
progressMessage
=
status
.
downloadSpeedText
;
app
.
status
.
total
=
status
.
totalLength
;
this
.
ref
.
tick
();
app
.
status
.
progressMessage
=
status
.
downloadSpeedText
;
});
this
.
ref
.
tick
();
});
}
catch
(
e
)
{
}
let
files
=
await
this
.
downloadService
.
getFiles
(
downloadId
);
let
files
=
await
this
.
downloadService
.
getFiles
(
downloadId
);
app
.
status
.
status
=
"
waiting
"
;
app
.
status
.
status
=
"
waiting
"
;
return
{
app
:
app
,
files
:
files
}
return
{
app
:
app
,
files
:
files
}
...
...
app/download.service.ts
View file @
97fd7c71
...
@@ -112,6 +112,7 @@ export class DownloadService {
...
@@ -112,6 +112,7 @@ export class DownloadService {
let
activeList
=
await
this
.
aria2
.
tellActive
();
let
activeList
=
await
this
.
aria2
.
tellActive
();
let
waitList
=
await
this
.
aria2
.
tellWaiting
(
0
,
MAX_LIST_NUM
);
let
waitList
=
await
this
.
aria2
.
tellWaiting
(
0
,
MAX_LIST_NUM
);
let
stoppedList
=
await
this
.
aria2
.
tellStopped
(
0
,
MAX_LIST_NUM
);
let
stoppedList
=
await
this
.
aria2
.
tellStopped
(
0
,
MAX_LIST_NUM
);
this
.
downloadList
.
clear
();
for
(
let
item
of
activeList
)
{
for
(
let
item
of
activeList
)
{
this
.
downloadList
.
set
(
item
.
gid
,
new
DownloadStatus
(
item
));
this
.
downloadList
.
set
(
item
.
gid
,
new
DownloadStatus
(
item
));
}
}
...
@@ -142,33 +143,41 @@ export class DownloadService {
...
@@ -142,33 +143,41 @@ export class DownloadService {
let
gids
=
this
.
taskMap
.
get
(
id
);
let
gids
=
this
.
taskMap
.
get
(
id
);
if
(
gids
)
{
if
(
gids
)
{
let
allStatus
:
DownloadStatus
;
let
allStatus
:
DownloadStatus
;
this
.
updateEmitter
.
subscribe
(()
=>
{
let
subscription
=
this
.
updateEmitter
.
subscribe
(()
=>
{
let
status
:
DownloadStatus
=
new
DownloadStatus
();
// 合并每个状态信息
try
{
status
=
let
status
:
DownloadStatus
=
new
DownloadStatus
();
gids
!
.
map
((
value
,
index
,
array
)
=>
{
// 合并每个状态信息
let
s
=
this
.
downloadList
.
get
(
value
);
status
=
if
(
!
s
)
{
gids
!
.
map
((
value
,
index
,
array
)
=>
{
throw
new
Error
(
"
Gid not Exists
"
);
let
s
=
this
.
downloadList
.
get
(
value
);
}
if
(
!
s
)
{
return
s
;
throw
"
Gid not exists
"
;
})
}
.
reduce
((
previousValue
,
currentValue
,
currentIndex
,
array
)
=>
{
return
s
;
return
previousValue
.
combine
(
currentValue
);
})
},
status
);
.
reduce
((
previousValue
,
currentValue
,
currentIndex
,
array
)
=>
{
if
(
!
allStatus
)
{
return
previousValue
.
combine
(
currentValue
);
allStatus
=
status
;
},
status
);
}
else
{
if
(
!
allStatus
)
{
if
(
allStatus
.
compareTo
(
status
)
!=
0
)
{
allStatus
=
status
;
allStatus
=
status
;
}
else
{
if
(
allStatus
.
compareTo
(
status
)
!=
0
)
{
allStatus
=
status
;
}
}
}
}
if
(
allStatus
.
status
===
"
error
"
)
{
if
(
allStatus
.
status
===
"
error
"
)
{
throw
`Download Error: code
${
allStatus
.
errorCode
}
, message:
${
allStatus
.
errorMessage
}
`
;
reject
(
`Download Error: code
${
allStatus
.
errorCode
}
, message:
${
allStatus
.
errorMessage
}
`
);
}
else
if
(
allStatus
.
status
===
"
complete
"
)
{
}
else
if
(
allStatus
.
status
===
"
complete
"
)
{
resolve
();
resolve
();
subscription
.
unsubscribe
();
}
else
{
}
else
{
callback
(
allStatus
);
callback
(
allStatus
);
}
}
catch
(
e
)
{
reject
(
e
);
subscription
.
unsubscribe
();
}
}
});
});
}
else
{
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment