Commit 64a41a1a authored by 神楽坂玲奈's avatar 神楽坂玲奈

版本0.4.6 正式

parent 1674f8de
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment