filbunke 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.1
@@ -1,18 +1,18 @@
1
1
  ---
2
2
  pid_file: '/var/run/filbunked.pid'
3
- user: 'bjorns'
3
+ user: 'daemon_user'
4
4
  log_file: '/tmp/filbunke.log'
5
5
  checkpoint_path: '/var/tmp/filbunke_checkpoints/'
6
6
  run_every: 5
7
- callback_path: '/Users/bjorns/Documents/Development/filbunke-cdn/client/doc/examples/'
7
+ callback_path: '/path/to/filebunke/config.yml'
8
8
  repositories:
9
9
  cache:
10
10
  local_path: '/v5/cachetest'
11
- filbunke_server_host: 'localhost'
11
+ filbunke_server_host: 'spebbe.local'
12
12
  filbunke_server_port: 8080
13
13
  filbunke_server_repository: 'cache'
14
14
  file_url_username: 'content'
15
- file_url_password: 'JeSuisContent#1'
15
+ file_url_password: 'contentpassword'
16
16
  file_umask: 0644
17
17
  directory_umask: 0755
18
18
  callbacks:
data/filbunke.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{filbunke}
8
- s.version = "1.1.0"
8
+ s.version = "1.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Wouter de Bie"]
@@ -24,20 +24,25 @@ module Filbunke
24
24
  def with_updated_files(last_checkpoint)
25
25
  updates = get_updated_file_list(last_checkpoint)
26
26
  updated_files = updates["files"] || []
27
+ failure = false
27
28
  updated_files.each do |raw_file|
28
29
  file = File.new(raw_file)
29
30
  if file.url.start_with?("http://")
30
31
  local_file_path = ::File.join(repository.local_path, file.path)
31
- update_http_file!(file, local_file_path)
32
- @callbacks.each do |callback|
33
- callback.on_update(file)
32
+ if update_http_file!(file, local_file_path) then
33
+ @callbacks.each do |callback|
34
+ callback.on_update(file)
35
+ end
36
+ yield file
37
+ else
38
+ @logger.log "Unable to get file #{file.url}/#{file.path}!"
39
+ failure = true
34
40
  end
35
- yield file
36
41
  else
37
42
  raise "Unsupported protocol for file: #{file.inspect}"
38
43
  end
39
44
  end
40
- updates["checkpoint"] || last_checkpoint
45
+ failure ? last_checkpoint : (updates["checkpoint"] || last_checkpoint)
41
46
  end
42
47
 
43
48
  def update_files!(last_checkpoint)
@@ -74,18 +79,24 @@ module Filbunke
74
79
  def get_updated_file_list(last_checkpoint)
75
80
  updates_http = Net::HTTP.new(@repository.host, @repository.port)
76
81
  updates_http.start do |http|
82
+ begin
77
83
  updates_path = "/#{UPDATES_ACTION}/#{@repository.name}?#{FROM_CHECKPOINT_KEY}=#{last_checkpoint}"
78
84
  request = Net::HTTP::Get.new(updates_path)
79
85
  response = http.request(request)
80
86
  if response.code.to_i == 200
81
87
  JSON.parse(response.body)
82
88
  else
83
- raise "Failed to download updates for #{@repository.name}, error code = #{response.code}"
89
+ @logger.log "Failed to download updates for #{@repository.name}, error code = #{response.code}"
90
+ end
91
+ rescue StandardError => e
92
+ @logger.log "Error getting file list: #{e.message}! Retrying later.."
93
+ {}
84
94
  end
85
95
  end
86
96
  end
87
97
 
88
98
  def update_http_file!(file, local_file_path)
99
+ begin
89
100
  uri = URI.parse(file.url)
90
101
  file_http=Net::HTTP.new(uri.host, uri.port)
91
102
  file_http.start do |http|
@@ -97,9 +108,14 @@ module Filbunke
97
108
  elsif response.code.to_i == 404
98
109
  delete_file!(local_file_path)
99
110
  else
100
- raise "Failed to update file #{uri}, error code = #{response.code}"
111
+ @logger.log "Failed to update file #{uri}, error code = #{response.code}"
101
112
  end
113
+ return true
114
+ end
115
+ rescue StandardError => e
116
+ return false
102
117
  end
118
+
103
119
  end
104
120
 
105
121
  def write_file!(file_path, contents)
@@ -53,7 +53,7 @@ module Filbunke
53
53
  end
54
54
 
55
55
  def update_checkpoint_for_repository(repository, checkpoint)
56
- @logger.log("Updating checkpoint for: #{repository.name}")
56
+ @logger.log("Updating checkpoint for: #{repository.name} to #{checkpoint}.")
57
57
  f = ::File.new(checkpoint_file_name_for_repository(repository), 'w', repository.file_umask)
58
58
  f.write(checkpoint)
59
59
  f.close
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 0
9
- version: 1.1.0
8
+ - 1
9
+ version: 1.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Wouter de Bie