six-updater-web 0.23.2 → 0.23.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/lib/six-updater-web/app/controllers/main_controller.rb +4 -0
- data/lib/six-updater-web/app/models/mod.rb +22 -24
- data/lib/six-updater-web/app/models/queryserver.rb +0 -1
- data/lib/six-updater-web/app/models/repository.rb +34 -0
- data/lib/six-updater-web/app/models/system_setting.rb +6 -0
- data/lib/six-updater-web/app/views/main/_left.haml +2 -0
- data/lib/six-updater-web/config/six-updater-web.rb +10 -1
- data/lib/six-updater-web/lib/tasks/sync.rake +5 -0
- metadata +3 -3
data/Rakefile
CHANGED
@@ -354,6 +354,10 @@ class MainController < ApplicationController
|
|
354
354
|
@msg << "Saved six-updater.yml!"
|
355
355
|
@msg << "<b>A window should open displaying the update process progress</b>"
|
356
356
|
|
357
|
+
when "speedtest"
|
358
|
+
@system_setting.speedtest
|
359
|
+
@msg << "<b>A window should open displaying the speedtest progress</b>"
|
360
|
+
|
357
361
|
when "stop game"
|
358
362
|
setting.kill!.each { |entry| @msg << "Process killed: #{entry}" }
|
359
363
|
sleep 1
|
@@ -20,6 +20,8 @@ class Mod < ActiveRecord::Base
|
|
20
20
|
mods += mod.all_dependentmods(mods)
|
21
21
|
mods << mod
|
22
22
|
end
|
23
|
+
mods -= [self]
|
24
|
+
mods += [self]
|
23
25
|
mods.uniq
|
24
26
|
end
|
25
27
|
|
@@ -73,14 +75,21 @@ class Mod < ActiveRecord::Base
|
|
73
75
|
self.version_local && !self.version_local.empty?
|
74
76
|
end
|
75
77
|
|
78
|
+
def my_path(setting)
|
79
|
+
return nil unless setting.real_modpath && self.real_name
|
80
|
+
File.join(self.real_path(setting), self.real_name).gsub("\\", "/")
|
81
|
+
end
|
82
|
+
|
76
83
|
def exists?(setting)
|
77
|
-
|
78
|
-
|
84
|
+
path = self.my_path(setting)
|
85
|
+
return false unless path
|
86
|
+
File.exists?(path)
|
79
87
|
end
|
80
88
|
|
81
89
|
def has_rsync?(setting)
|
82
|
-
|
83
|
-
|
90
|
+
path = self.my_path(setting)
|
91
|
+
return false unless path
|
92
|
+
File.exists?(File.join(path, ".rsync"))
|
84
93
|
end
|
85
94
|
|
86
95
|
def remote
|
@@ -94,20 +103,10 @@ class Mod < ActiveRecord::Base
|
|
94
103
|
def read_version(path)
|
95
104
|
return unless path && self.real_name
|
96
105
|
cfg = File.join(path, self.real_name, '.rsync', '.repository.yml')
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
conf[:version]
|
102
|
-
rescue
|
103
|
-
nil
|
104
|
-
end
|
105
|
-
else
|
106
|
-
nil
|
107
|
-
end
|
108
|
-
else
|
109
|
-
nil
|
110
|
-
end
|
106
|
+
return nil unless File.exists?(cfg)
|
107
|
+
conf = YAML::load_file(cfg)
|
108
|
+
return nil unless conf
|
109
|
+
begin; conf[:version]; rescue; nil; end
|
111
110
|
end
|
112
111
|
|
113
112
|
def update_version(path)
|
@@ -120,21 +119,20 @@ class Mod < ActiveRecord::Base
|
|
120
119
|
end
|
121
120
|
|
122
121
|
def real_path(appsetting)
|
123
|
-
|
124
|
-
self.path
|
125
|
-
else
|
126
|
-
appsetting.real_modpath
|
127
|
-
end
|
122
|
+
self.path ? self.path : appsetting.real_modpath
|
128
123
|
end
|
129
124
|
|
130
125
|
def all_repositories
|
131
|
-
if self.networks.empty?
|
126
|
+
rep = if self.networks.empty?
|
132
127
|
Repository.find(:all)
|
133
128
|
else
|
134
129
|
repos = []
|
135
130
|
self.networks.each { |net| repos += net.repositories unless net.disabled }
|
136
131
|
repos
|
137
132
|
end
|
133
|
+
prio = nil
|
134
|
+
rep.each {|e| unless e.priority.nil?; prio = true; break; end }
|
135
|
+
prio ? rep.sort{|a, b| a.priority <=> b.priority} : rep.shuffle
|
138
136
|
end
|
139
137
|
|
140
138
|
def update_skip
|
@@ -2,6 +2,40 @@ class Repository < ActiveRecord::Base
|
|
2
2
|
belongs_to :network
|
3
3
|
six_guid
|
4
4
|
|
5
|
+
attr_accessor :ping_value
|
6
|
+
|
7
|
+
def self.rank(pr = false)
|
8
|
+
repos = self.find(:all)
|
9
|
+
repos.each do |rep|
|
10
|
+
puts "Processing #{rep.url}" if pr
|
11
|
+
rep.ping_value = rep.ping!
|
12
|
+
sleep 1
|
13
|
+
end
|
14
|
+
repos.sort!{|a, b| a.ping_value <=> b.ping_value }
|
15
|
+
repos.each_with_index do |rep,index|
|
16
|
+
rep.priority = index
|
17
|
+
rep.save
|
18
|
+
end
|
19
|
+
repos
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def ping!
|
24
|
+
logger.info "Handling #{self.address}"
|
25
|
+
out = %x[ping -n 10 #{self.address}]
|
26
|
+
vals = []
|
27
|
+
out.each_line do |l|
|
28
|
+
l[/=([0-9]*)ms/]
|
29
|
+
if $1
|
30
|
+
vals << $1.to_i
|
31
|
+
end
|
32
|
+
end
|
33
|
+
logger.debug "Out: #{out}, Vals: #{vals}"
|
34
|
+
bla = 0
|
35
|
+
vals.each {|v| bla += v }
|
36
|
+
bla == 0 ? 9999 : bla / vals.size
|
37
|
+
end
|
38
|
+
|
5
39
|
def ping
|
6
40
|
SixUpdaterWeb.run_program("ping", SixUpdaterWeb::BASE_PATH, "-r 9 -n 30 -t #{self.address}")
|
7
41
|
end
|
@@ -14,6 +14,12 @@ class SystemSetting < ActiveRecord::Base
|
|
14
14
|
"rake" # .bat on Windows
|
15
15
|
end
|
16
16
|
|
17
|
+
def speedtest
|
18
|
+
cl = "sync:priority RAILS_ENV=#{ENV['RAILS_ENV']}" # + cl
|
19
|
+
cl += " BASE_PATH=\'#{SixUpdaterWeb::BASE_PATH}\'" if defined?(SixUpdaterWeb::OLDLOCATION)
|
20
|
+
SixUpdaterWeb.run_program(exec, RAILS_ROOT, cl)
|
21
|
+
end
|
22
|
+
|
17
23
|
def update_gamespy(internal = false)
|
18
24
|
self.gamespied_at = Time.now
|
19
25
|
self.save
|
@@ -22,7 +22,7 @@ case RUBY_VERSION
|
|
22
22
|
end
|
23
23
|
|
24
24
|
module SixUpdaterWeb
|
25
|
-
VERSION = "0.23.
|
25
|
+
VERSION = "0.23.3"
|
26
26
|
COMPONENT = "six-updater-web"
|
27
27
|
|
28
28
|
DEFAULT_IP = "127.0.0.1" unless defined?(DEFAULT_IP)
|
@@ -207,6 +207,15 @@ module SixUpdaterWeb
|
|
207
207
|
puts "Done!"
|
208
208
|
end
|
209
209
|
|
210
|
+
def mirror_priority
|
211
|
+
puts "Checking mirror latencies, please be patient..."
|
212
|
+
repos = Repository.rank(true)
|
213
|
+
puts
|
214
|
+
repos.each do |rep|
|
215
|
+
puts "#{rep.priority} - #{rep.ping_value} - #{rep.url}"
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
210
219
|
def logger
|
211
220
|
ActiveRecord::Base.logger
|
212
221
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 23
|
8
|
-
-
|
9
|
-
version: 0.23.
|
8
|
+
- 3
|
9
|
+
version: 0.23.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Sickboy
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-07-
|
17
|
+
date: 2010-07-26 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|