ruby-livesync 1.0.0.beta4 → 1.0.0.beta5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e77356b7dfd5070935875d4842a16129c5d1eeaaec1e049d2b4e4824032a2c0
4
- data.tar.gz: f8350e318d1f3e31dc5925981c1526b74d404795c4300419a2db489ff38e0f2a
3
+ metadata.gz: 182e21dbd5e045ed2de4492cdefcd295dd92f9af62154ce4cfb7569610cd55ee
4
+ data.tar.gz: c3d0fe0760f40b408b9e3b72d0349dcf5a838f8aff1224ae2de424af508947fb
5
5
  SHA512:
6
- metadata.gz: 9989027e61b51d31e4248e71c7d24e3d1a8c9cfaf74ab532cd99fcc6f25ae7d9e23c12790cc31a57e306395213c846e132e3cdc24c6d14d548f74d525860515d
7
- data.tar.gz: 43ac4cf5d5ff1cc2926bb13ba60f4efbafa07fd54d940d8bdb55cbd183b6a608c6d644a4a7173c2ebdf1d490534eedd37e1940ef9854b98b16201d3461be5009
6
+ metadata.gz: 76aa54c57ad5ee3b64fcee946432021d5e5e948125ffaf72c524bb81bd2abdfefbd53138a67772d05e557690b6ffb89cf608b6267ac124fcb3f0ecc84f59d9e1
7
+ data.tar.gz: b38edffeb1ae8e63d20346cebf2510da50950bd621d2bf8cf864d0975915b8ee91d823299449cc294225b9c657b966df9e2b934c5a22fe21a988c03e82b41e61
@@ -25,13 +25,13 @@ module LiveSync
25
25
 
26
26
  Thread.new do
27
27
  stdout.sync = true
28
- lines = stdout.each_line.each do |line|
28
+ stdout.each_line.each do |line|
29
29
  file,events = parse line
30
30
  yield [OpenStruct.new(absolute_name: file, flags: events)]
31
31
  end
32
32
  end
33
33
  Thread.new do
34
- STDERR.puts stderr.read
34
+ stderr.each_line.each{ |line| STDERR.puts line }
35
35
  end
36
36
  end
37
37
 
@@ -1,11 +1,13 @@
1
1
  import pyinotify
2
2
  import os
3
3
  import time
4
+ import sys
4
5
 
5
6
  class EventHandler(pyinotify.ProcessEvent):
6
- def my_init(self, excludes, recursive, mask):
7
+ def my_init(self, excludes, recursive, mask, base_device):
7
8
  self.excludes = excludes
8
9
  self.recursive = recursive
10
+ self.base_device = base_device
9
11
  self.mask = mask
10
12
  self.events = set()
11
13
 
@@ -21,15 +23,32 @@ class EventHandler(pyinotify.ProcessEvent):
21
23
  print(f"{event_desc} {full_path}", flush=True)
22
24
  self.events.clear()
23
25
 
26
+ def watch_path(self, path):
27
+ if not any(exclude in path for exclude in self.excludes):
28
+ try:
29
+ if os.stat(path).st_dev == self.base_device:
30
+ wm.add_watch(path, self.mask, auto_add=True)
31
+ else:
32
+ print(f"Skipping {path} (different device)", file=sys.stderr)
33
+ except Exception as e:
34
+ print(f"Error adding watch on {path}: {e}", file=sys.stderr)
35
+
24
36
  def add_watch(self, path):
25
- wm.add_watch(path, self.mask, rec=self.recursive, auto_add=True)
37
+ if self.recursive:
38
+ for root, dirs, _ in os.walk(path):
39
+ self.watch_path(root)
40
+ for dir in dirs:
41
+ self.watch_path(os.path.join(root, dir))
42
+ else:
43
+ self.watch_path(path)
26
44
 
27
- excludes = [%{excludes}]
28
- recursive = %{recursive}
29
- event_mask = pyinotify.IN_CREATE | pyinotify.IN_MODIFY | pyinotify.IN_MOVED_TO | pyinotify.IN_DELETE # Event mask
45
+ excludes = [%{excludes}]
46
+ recursive = %{recursive}
47
+ event_mask = pyinotify.IN_CREATE | pyinotify.IN_MODIFY | pyinotify.IN_MOVED_TO | pyinotify.IN_DELETE # Event mask
48
+ base_device = os.stat('%{path}').st_dev
30
49
 
31
50
  wm = pyinotify.WatchManager()
32
- handler = EventHandler(excludes=excludes, recursive=recursive, mask=event_mask)
51
+ handler = EventHandler(excludes=excludes, recursive=recursive, mask=event_mask, base_device=base_device)
33
52
  notifier = pyinotify.Notifier(wm, handler)
34
53
  handler.add_watch('%{path}')
35
54
 
@@ -1,7 +1,7 @@
1
1
  module LiveSync
2
2
  class Rsync < Target
3
3
 
4
- dsl :opts, type: String
4
+ dsl :opts, default: '-ax --partial', type: String
5
5
 
6
6
  attr_reader :ssh
7
7
 
@@ -1,5 +1,5 @@
1
1
  module LiveSync
2
2
 
3
- VERSION = '1.0.0.beta4'
3
+ VERSION = '1.0.0.beta5'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-livesync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta4
4
+ version: 1.0.0.beta5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braulio Oliveira