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
xiaoye
mycard
Commits
6e5905af
Commit
6e5905af
authored
Feb 19, 2013
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
5525f86e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
8 deletions
+19
-8
lib/update.rb
lib/update.rb
+19
-8
No files found.
lib/update.rb
View file @
6e5905af
...
@@ -130,6 +130,7 @@ module Update
...
@@ -130,6 +130,7 @@ module Update
require
'net/http/pipeline'
require
'net/http/pipeline'
@thumbnails_left
=
@thumbnails
.
size
@thumbnails_left
=
@thumbnails
.
size
@images_left
=
@images
.
size
@images_left
=
@images
.
size
@error_count
=
0
threads
=
5
.
times
.
collect
do
threads
=
5
.
times
.
collect
do
thread
=
Thread
.
new
do
thread
=
Thread
.
new
do
Net
::
HTTP
.
start
uri
.
host
,
uri
.
port
do
|
http
|
Net
::
HTTP
.
start
uri
.
host
,
uri
.
port
do
|
http
|
...
@@ -141,12 +142,17 @@ module Update
...
@@ -141,12 +142,17 @@ module Update
ids
.
replace
@thumbnails
.
pop
(
100
)
ids
.
replace
@thumbnails
.
pop
(
100
)
reqs
=
ids
.
reverse
.
collect
{
|
id
|
Net
::
HTTP
::
Get
.
new
thumbnail_req
.
gsub
(
':id'
,
id
.
to_s
)
}
reqs
=
ids
.
reverse
.
collect
{
|
id
|
Net
::
HTTP
::
Get
.
new
thumbnail_req
.
gsub
(
':id'
,
id
.
to_s
)
}
http
.
pipeline
reqs
do
|
res
|
http
.
pipeline
reqs
do
|
res
|
@status
.
replace
"正在下载卡图 (剩余: 缩略
#{
@thumbnails_left
}
/ 完整
#{
@images_left
}
)"
@status
.
replace
"正在下载卡图 (剩余: 缩略
#{
@thumbnails_left
}
/ 完整
#{
@images_left
}
#{
"错误:
#{
@error_count
}
"
if
@error_count
>
0
}
)"
@thumbnails_left
-=
1
@thumbnails_left
-=
1
id
=
ids
.
pop
id
=
ids
.
pop
next
if
File
.
file?
"ygocore/pics/thumbnail/
#{
id
}
.jpg"
if
res
.
code
[
0
]
==
'2'
#http 2xx
content
=
res
.
body
next
if
File
.
file?
"ygocore/pics/thumbnail/
#{
id
}
.jpg"
open
(
"ygocore/pics/thumbnail/
#{
id
}
.jpg"
,
'wb'
)
{
|
local
|
local
.
write
content
}
content
=
res
.
body
open
(
"ygocore/pics/thumbnail/
#{
id
}
.jpg"
,
'wb'
)
{
|
local
|
local
.
write
content
}
else
$log
.
warn
(
"下载缩略卡图
#{
id
}
出错"
){
res
}
@error_count
+=
1
end
end
end
end
end
list
=
@images
list
=
@images
...
@@ -155,12 +161,17 @@ module Update
...
@@ -155,12 +161,17 @@ module Update
ids
.
replace
@images
.
pop
(
100
)
ids
.
replace
@images
.
pop
(
100
)
reqs
=
ids
.
reverse
.
collect
{
|
id
|
Net
::
HTTP
::
Get
.
new
image_req
.
gsub
(
':id'
,
id
.
to_s
)
}
reqs
=
ids
.
reverse
.
collect
{
|
id
|
Net
::
HTTP
::
Get
.
new
image_req
.
gsub
(
':id'
,
id
.
to_s
)
}
http
.
pipeline
reqs
do
|
res
|
http
.
pipeline
reqs
do
|
res
|
@status
.
replace
"正在下载卡图 (剩余: 缩略
#{
@thumbnails_left
}
/ 完整
#{
@images_left
}
)"
@status
.
replace
"正在下载卡图 (剩余: 缩略
#{
@thumbnails_left
}
/ 完整
#{
@images_left
}
#{
"错误:
#{
@error_count
}
"
if
@error_count
>
0
}
)"
@images_left
-=
1
@images_left
-=
1
id
=
ids
.
pop
id
=
ids
.
pop
next
if
File
.
file?
"ygocore/pics/
#{
id
}
.jpg"
if
res
.
code
[
0
]
==
'2'
#http 2xx
content
=
res
.
body
next
if
File
.
file?
"ygocore/pics/
#{
id
}
.jpg"
open
(
"ygocore/pics/
#{
id
}
.jpg"
,
'wb'
)
{
|
local
|
local
.
write
content
}
content
=
res
.
body
open
(
"ygocore/pics/
#{
id
}
.jpg"
,
'wb'
)
{
|
local
|
local
.
write
content
}
else
$log
.
warn
(
"下载完整卡图
#{
id
}
出错"
){
res
}
@error_count
+=
1
end
end
end
end
end
rescue
rescue
...
...
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