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
64a41a1a
Commit
64a41a1a
authored
Mar 27, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
版本0.4.6 正式
parent
1674f8de
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
24 deletions
+58
-24
lib/update.rb
lib/update.rb
+58
-24
No files found.
lib/update.rb
View file @
64a41a1a
require
'open-uri'
require_relative
'card'
module
Update
Version
=
'0.4.6'
URL
=
'http://card.touhou.cc/mycard/update.json?version=0.4.6'
...
...
@@ -27,7 +28,7 @@ module Update
end
if
@updated
IO
.
popen
(
'./mycard'
)
exit
$scene
=
nil
end
@status
=
'正在检查更新'
Thread
.
new
do
...
...
@@ -76,6 +77,38 @@ module Update
end
end
@images
-=
existed_images
existed_images
=
[]
if
!
@images
.
empty?
and
File
.
file?
(
"
#{
Card
::
PicPath
}
/1.jpg"
)
db_mycard
=
SQLite3
::
Database
.
new
(
"data/data.sqlite"
)
can_link
=
true
db_mycard
.
execute
(
"select id, number from `yu-gi-oh` where number in (
#{
@images
.
collect
{
|
number
|
"%08d"
%
number
}
.join(',')})"
)
do
|
row
|
id
=
row
[
0
]
number
=
row
[
1
].
to_i
existed_images
<<
number
src
=
"
#{
Card
::
PicPath
}
/
#{
id
}
.jpg"
dest
=
"ygocore/pics/
#{
number
}
.jpg"
if
File
.
file?
(
src
)
and
!
File
.
file?
(
dest
)
@status
.
replace
"检测到存在iDuel卡图 正在导入
#{
id
}
.jpg"
if
can_link
begin
File
.
link
(
src
,
dest
)
rescue
can_link
=
false
redo
end
else
open
(
src
,
'rb'
)
do
|
src
|
open
(
dest
,
'wb'
)
do
|
dest
|
dest
.
write
src
.
read
end
end
end
end
end
end
@images
-=
existed_images
@thumbnails
=
(
@thumbnails
&
@images
)
+
(
@thumbnails
-
@images
)
unless
@thumbnails
.
empty?
and
@images
.
empty?
$log
.
info
(
'待下载的完整卡图'
){
@images
.
inspect
}
threads
=
5
.
times
.
collect
do
thread
=
Thread
.
new
do
...
...
@@ -103,9 +136,10 @@ module Update
end
threads
.
each
{
|
thread
|
thread
.
join
}
end
end
end
rescue
nil
@status
=
nil
end
end
.
priority
=
-
1
end
end
end
\ No newline at end of file
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