Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
console
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
MyCard
console
Commits
6c7dbe8c
Commit
6c7dbe8c
authored
May 03, 2017
by
nano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
1077e608
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
151 additions
and
115 deletions
+151
-115
.idea/workspace.xml
.idea/workspace.xml
+89
-102
config.ts
config.ts
+2
-2
src/routes/package.ts
src/routes/package.ts
+26
-2
test.ts
test.ts
+23
-9
views/update.hbs
views/update.hbs
+11
-0
No files found.
.idea/workspace.xml
View file @
6c7dbe8c
This diff is collapsed.
Click to expand it.
config.ts
View file @
6c7dbe8c
...
...
@@ -12,7 +12,7 @@ export default {
new_package
:
`
${
baseUrl
}
/v1/package/`
,
new_app
:
(
appId
)
=>
`
${
baseUrl
}
/v1/app/
${
appId
}
`
,
old_metalinks
:
(
package_id
)
=>
`https://cdn01.moecube.com/release/metalinks/
${
package_id
}
.meta4`
,
new_metalinks
:
(
package_id
)
=>
`
${
baseUrl
}
/
${
package_id
}
/meta`
,
new_metalinks
:
(
package_id
)
=>
`
${
baseUrl
}
/
v2/package-legacy/
${
package_id
}
/meta`
,
old_checksums
:
(
package_id
)
=>
`https://cdn01.moecube.com/release/checksums/
${
package_id
}
`
,
new_checksums
:
(
package_id
)
=>
`
${
baseUrl
}
/
${
package_id
}
/checksum`
,
new_checksums
:
(
package_id
)
=>
`
${
baseUrl
}
/
v2/package-legacy/
${
package_id
}
/checksum`
,
};
src/routes/package.ts
View file @
6c7dbe8c
...
...
@@ -2,7 +2,6 @@ import Router = require('koa-router');
import
{
toObjectID
}
from
'
iridium
'
;
import
{
mongodb
}
from
'
../models/Iridium
'
;
import
{
Context
}
from
'
koa
'
;
import
config
from
'
../../config
'
;
import
{
Archive
,
Package
}
from
'
../models/Package
'
;
import
{
renderChecksum
}
from
'
../utils
'
;
const
router
=
new
Router
();
...
...
@@ -15,7 +14,16 @@ router.get('/v2/packages', async (ctx: Context, next) => {
appId
:
ctx
.
request
.
query
.
appId
,
status
:
'
uploaded
'
}).
toArray
();
ctx
.
body
=
packs
ctx
.
body
=
packs
;
});
router
.
get
(
'
/v2/package-legacy/:id/checksum
'
,
async
(
ctx
:
Context
,
next
)
=>
{
let
pack
=
await
mongodb
.
Packages
.
findOne
({
appId
:
ctx
.
params
.
id
,
status
:
'
uploaded
'
});
if
(
!
pack
)
{
return
ctx
.
throw
(
400
,
'
pack error
'
);
}
ctx
.
body
=
renderChecksum
(
pack
.
files
);
});
...
...
@@ -44,6 +52,22 @@ router.get('/v2/package/:id/meta', async (ctx: Context, next) => {
});
});
router
.
get
(
'
/v2/package-legacy/:id/meta
'
,
async
(
ctx
:
Context
,
next
)
=>
{
let
pack
=
await
mongodb
.
Packages
.
findOne
({
appId
:
ctx
.
params
.
id
,
status
:
'
uploaded
'
});
if
(
!
pack
)
{
return
ctx
.
throw
(
400
,
'
pack error
'
);
}
await
ctx
[
'
render
'
](
'
update
'
,
{
files
:
{
name
:
pack
.
id
,
size
:
pack
.
fullSize
,
hash
:
pack
.
fullHash
}
});
});
router
.
post
(
'
/v2/package/:id/update
'
,
async
(
ctx
:
Context
,
next
)
=>
{
const
package_id
=
ctx
.
params
.
id
;
const
request_overhead
=
1024
*
1024
;
...
...
test.ts
View file @
6c7dbe8c
...
...
@@ -11,15 +11,24 @@ async function test_checksums() {
const
apps
:
any
[]
=
(
await
(
await
fetch
(
config
.
new_apps_json
)).
json
())
.
filter
(
i
=>
!
[
'
ygopro
'
,
'
desmume
'
].
includes
(
i
.
id
));
// 排除 ygopro 和 desmume
for
(
let
app
of
_
.
sampleSize
(
apps
,
5
))
{
let
oldMaps
=
new
Set
();
for
(
let
app
of
apps
)
{
console
.
log
(
`正在测试
${
app
.
id
}
的 checksum`
);
const
old_checksum
=
await
(
await
fetch
(
config
.
old_checksums
(
app
.
id
))).
text
();
const
new_checksum
=
await
(
await
fetch
(
config
.
new_checksums
(
app
.
id
))).
text
();
if
(
old_checksum
!==
new_checksum
)
{
old_checksum
.
split
(
'
\n
'
).
forEach
(
line
=>
{
oldMaps
.
add
(
line
);
});
new_checksum
.
split
(
'
\n
'
).
forEach
(
line
=>
{
if
(
!
oldMaps
.
has
(
line
))
{
console
.
log
(
'
旧
'
,
old_checksum
);
console
.
log
(
'
新
'
,
new_checksum
);
throw
`应用
${
app
.
id
}
的 checksum 不一致`
;
}
});
}
}
async
function
test_download
()
{
...
...
@@ -71,9 +80,14 @@ async function test_apps_json() {
async
function
main
()
{
// await test_apps_json();
try
{
await
test_checksums
();
await
test_download
();
await
test_update
();
}
catch
(
e
)
{
console
.
log
(
e
);
}
console
.
log
(
'
ok
'
);
}
...
...
views/update.hbs
0 → 100644
View file @
6c7dbe8c
<?xml version="1.0" encoding="UTF-8"?>
<metalink
xmlns=
"urn:ietf:params:xml:ns:metalink"
>
{{#
files
}}
<file
name=
"
{{
name
}}
"
>
<size>
{{
size
}}
</size>
<hash
type=
"sha-256"
>
{{
hash
}}
</hash>
<url
priority=
"1"
>
https://cdn01.moecube.com/test-release/
{{
hash
}}
.tar.gz
</url>
<url
priority=
"1"
>
https://cdn01.moecube.com/test-release/
{{
hash
}}
.tar.gz
</url>
</file>
{{/
files
}}
</metalink>
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