xrefresh-server 0.2.2 → 0.3.0

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.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/xrefresh-server/monitor.rb +19 -6
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.3.0
@@ -1,6 +1,7 @@
1
1
  require 'osx/foundation'
2
2
  OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
3
3
  include OSX
4
+ require 'digest/md5'
4
5
 
5
6
  module XRefreshServer
6
7
 
@@ -12,6 +13,7 @@ module XRefreshServer
12
13
  @modified_dirs = Set.new
13
14
  @paths_info = Hash.new
14
15
  @streams = []
16
+ @checksums = Hash.new
15
17
  end
16
18
 
17
19
  def schedule(start_event_id)
@@ -51,6 +53,13 @@ module XRefreshServer
51
53
  end
52
54
  end
53
55
 
56
+ def checksum_modified?(full_path)
57
+ digest = Digest::MD5.hexdigest(File.read(full_path))
58
+ return false if (@checksums[full_path]==digest)
59
+ @checksums[full_path]=digest
60
+ true
61
+ end
62
+
54
63
  # blocking call
55
64
  def run_loop(start_time)
56
65
 
@@ -110,12 +119,16 @@ module XRefreshServer
110
119
  if (current_time > original_time)
111
120
  OUT.puts "debug: reported #{full_path}" if @config["debug"]
112
121
  relative_path = full_path[root.size+1..-1]
113
- buckets[root]||=[]
114
- buckets[root]<< {
115
- "action" => "changed",
116
- "path1" => relative_path,
117
- "path2" => nil
118
- }
122
+ if (checksum_modified?(full_path))
123
+ buckets[root]||=[]
124
+ buckets[root]<< {
125
+ "action" => "changed",
126
+ "path1" => relative_path,
127
+ "path2" => nil
128
+ }
129
+ else
130
+ OUT.puts "debug: not accepted - checksum is the same" if @config["debug"]
131
+ end
119
132
  end
120
133
  @paths_info[full_path] = current_time
121
134
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xrefresh-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antonin Hildebrand
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-21 00:00:00 +02:00
12
+ date: 2009-07-27 00:00:00 +02:00
13
13
  default_executable: xrefresh-server
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  requirements: []
74
74
 
75
75
  rubyforge_project: xrefresh-server
76
- rubygems_version: 1.3.4
76
+ rubygems_version: 1.3.5
77
77
  signing_key:
78
78
  specification_version: 3
79
79
  summary: XRefresh filesystem monitor for OSX