snapsync 0.1.6 → 0.1.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f9224076ddb7de222c830cb7ad068742631d46b
4
- data.tar.gz: b3ced85dbdc080938b61ec158e8d803f72ebeed1
3
+ metadata.gz: 62c200ca50a3f1aa39d7ba8ece8167cedd05dd09
4
+ data.tar.gz: fe946f70afa36619c9aa307704762a4a9d4afb81
5
5
  SHA512:
6
- metadata.gz: c26502e714514d0d8f686c62a3d237ded6c85f0cd1a665b2d55d340d357c40aa139a36d5040f371fc719d80aa1c7010654199b6de47b3f2534bae1a3871bb56d
7
- data.tar.gz: 0c67490d86f8ad9fc007e88a7c9054883be9f45ee94410ca18dd55dbc6e422620b90f33406693ff44817a13c70f262253cc9283f568035a50b2b029b2ae56aa8
6
+ metadata.gz: 746d7b8a0c4b18a9aa121de9dfb7a03ceeec4492a8f8c4143a907505d2555c0c778166f55026d932ee482c1e8be0475443175e8e5917e716271b010918bb4805
7
+ data.tar.gz: cb76bb425572ea908df6a5c1609a73e17a2ff37cf725b64373e7fbdb6c5eaf744cd3f8000c3490194ec0c4e6d28ee22fb500b1e1af9e655b44e650e070a4a535
@@ -125,8 +125,8 @@ module Snapsync
125
125
  return enum_for(__method__) if !block_given?
126
126
  each_available_autosync_target do |path, t|
127
127
  op = SyncAll.new(path, config_dir: config_dir)
128
- op.each_target do |target|
129
- yield(target)
128
+ op.each_target do |config, target|
129
+ yield(config, target)
130
130
  end
131
131
  end
132
132
  end
@@ -26,14 +26,19 @@ module Snapsync
26
26
  filtered_snapshots << last_sync_point
27
27
  filtered_snapshots = filtered_snapshots.to_set
28
28
 
29
- snapshots.sort_by(&:num).each do |s|
29
+ deleted_snapshots = snapshots.sort_by(&:num).find_all do |s|
30
30
  if !filtered_snapshots.include?(s)
31
31
  target.delete(s, dry_run: dry_run)
32
+ true
32
33
  end
33
34
  end
34
35
 
35
- Snapsync.info "Waiting for subvolumes to be deleted"
36
- IO.popen(["btrfs", "subvolume", "sync", err: '/dev/null']).read
36
+ if !deleted_snapshots.empty?
37
+ Snapsync.info "Waiting for subvolumes to be deleted"
38
+ deleted_snapshots.each do |s|
39
+ IO.popen(["btrfs", "subvolume", "sync", s.subvolume_dir.to_s, err: '/dev/null']).read
40
+ end
41
+ end
37
42
  end
38
43
  end
39
44
  end
data/lib/snapsync/cli.rb CHANGED
@@ -42,13 +42,13 @@ module Snapsync
42
42
  rescue LocalTarget::InvalidTargetPath
43
43
  end
44
44
 
45
- SyncAll.new(dir).each_target do |target|
46
- yield(target)
45
+ SyncAll.new(dir).each_target do |config, target|
46
+ yield(config, target)
47
47
  end
48
48
  else
49
49
  autosync = AutoSync.load_default
50
- autosync.each_available_target do |target|
51
- yield(target)
50
+ autosync.each_available_target do |config, target|
51
+ yield(config, target)
52
52
  end
53
53
  end
54
54
  end
@@ -73,6 +73,7 @@ module Snapsync
73
73
  def sync_all(dir)
74
74
  handle_class_options
75
75
 
76
+ dir = Pathname.new(dir)
76
77
  op = SyncAll.new(dir, config_dir: SnapperConfig.default_config_dir, autoclean: options[:autoclean])
77
78
  op.run
78
79
  end
@@ -196,7 +197,7 @@ for 10 days). snapsync understands the following period names: year month day ho
196
197
  EOD
197
198
  def policy(dir, type, *options)
198
199
  handle_class_options
199
- each_target(dir) do |target|
200
+ each_target(dir) do |_, target|
200
201
  target.change_policy(type, options)
201
202
  target.write_config
202
203
  end
@@ -230,7 +231,7 @@ While it can easily be done manually, this command makes sure that the snapshots
230
231
  desc 'list [DIR]', 'list the snapshots present on DIR. If DIR is omitted, tries to access all targets defined as auto-sync targets'
231
232
  def list(dir = nil)
232
233
  handle_class_options
233
- each_target(dir) do |target|
234
+ each_target(dir) do |_, target|
234
235
  puts "== #{target.dir}"
235
236
  puts "UUID: #{target.uuid}"
236
237
  puts "Enabled: #{target.enabled?}"
@@ -40,13 +40,13 @@ module Snapsync
40
40
  if !dir.exist?
41
41
  Snapsync.warn "no directory for configuration #{config.name} in #{target_dir}"
42
42
  else
43
- yield(LocalTarget.new(dir))
43
+ yield(config, LocalTarget.new(dir))
44
44
  end
45
45
  end
46
46
  end
47
47
 
48
48
  def run
49
- each_target do |target|
49
+ each_target do |config, target|
50
50
  if !target.enabled?
51
51
  Snapsync.warn "not synchronizing to #{target.dir}, it is disabled"
52
52
  next
@@ -1,3 +1,3 @@
1
1
  module Snapsync
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snapsync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Joyeux