Commit 75237d5b authored by 神楽坂玲奈's avatar 神楽坂玲奈

fix

parent e95c0c7e
......@@ -20,7 +20,7 @@ end
spec = Gem::Specification.new do |s|
s.name = 'mycard'
s.version = '1.1.3'
s.version = '1.2.0'
s.extra_rdoc_files = ['README.txt', 'LICENSE.txt']
s.summary = 'a card game platform'
s.description = s.summary
......
......@@ -10,7 +10,7 @@ module Deck_Sync
require 'date'
Thread.new {
just_updated = []
$log.info('下载卡组'){"https://my-card.in/decks/?user=#{URI.escape $game.user.id.bare.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")}"}
$log.info('下载卡组') { "https://my-card.in/decks/?user=#{URI.escape $game.user.id.bare.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")}" }
open("https://my-card.in/decks/?user=#{URI.escape $game.user.id.bare.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")}") { |list|
JSON.parse(list.read).each { |deck|
file = File.join(File.dirname(Ygocore.ygocore_path), 'deck', "#{deck['name']}.ydk")
......@@ -38,7 +38,10 @@ module Deck_Sync
} rescue $log.error('卡组下载') { [$!.inspect, *$!.backtrace].collect { |str| str.force_encoding("UTF-8") }.join("\n") }
Thread.new { watch } unless @watching
@watching = true
Dir.glob(File.join(File.dirname(Ygocore.ygocore_path), 'deck', '*.ydk')) { |deck|
Dir.foreach(File.join(File.dirname(Ygocore.ygocore_path), 'deck')) { |deck|
deck.encode! 'UTF-8'
deck = File.join(File.dirname(Ygocore.ygocore_path), 'deck', deck)
next if File.extname(deck) != '.ydk'
next if just_updated.include? deck
update(deck)
}
......@@ -63,6 +66,7 @@ module Deck_Sync
response = Net::HTTP.start('my-card.in', 443, use_ssl: true) { |http| http.request(req) }
Update.status = nil
end
def delete(deck)
Update.status = "正在同步卡组: #{File.basename(deck, ".ydk")}"
path = "/decks/?name=#{URI.escape File.basename(deck, ".ydk"), Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")}&user=#{URI.escape $game.user.id.bare.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")}"
......
......@@ -47,7 +47,7 @@ module Update
$log.info('下载更新-解析后') { reply.inspect }
reply.each do |fil|
name = File.basename fil
@status.replace "正在下载更新#{name}"
@status = "正在下载更新#{name}"
open(fil, 'rb') do |fi|
$log.info('下载完毕') { name }
@updated = true
......@@ -102,7 +102,7 @@ module Update
dest = "ygocore/pics/#{number}.jpg"
dest_thumb = "ygocore/pics/thumbnail/#{number}.jpg"
if File.file?(src)
@status.replace "检测到存在iDuel卡图 正在导入 #{id}.jpg"
@status = "检测到存在iDuel卡图 正在导入 #{id}.jpg"
existed_images << number
if !File.exist?(dest)
FileUtils.copy_file(src, dest)
......@@ -148,7 +148,7 @@ module Update
ids.replace @thumbnails.pop(100)
reqs = ids.reverse.collect { |id| Net::HTTP::Get.new thumbnail_req.gsub(':id', id.to_s) }
http.pipeline reqs do |res|
@status.replace "正在下载卡图 (剩余: 缩略#{@thumbnails_left} / 完整#{@images_left} #{"错误: #{@error_count}" if @error_count > 0})"
@status = "正在下载卡图 (剩余: 缩略#{@thumbnails_left} / 完整#{@images_left} #{"错误: #{@error_count}" if @error_count > 0})"
@thumbnails_left -= 1
id = ids.pop
if res.code[0] == '2' #http 2xx
......@@ -167,7 +167,7 @@ module Update
ids.replace @images.pop(100)
reqs = ids.reverse.collect { |id| Net::HTTP::Get.new image_req.gsub(':id', id.to_s) }
http.pipeline reqs do |res|
@status.replace "正在下载卡图 (剩余: 缩略#{@thumbnails_left} / 完整#{@images_left} #{"错误: #{@error_count}" if @error_count > 0})"
@status = "正在下载卡图 (剩余: 缩略#{@thumbnails_left} / 完整#{@images_left} #{"错误: #{@error_count}" if @error_count > 0})"
@images_left -= 1
id = ids.pop
if res.code[0] == '2' #http 2xx
......
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