vagrant-zscp 0.1.4 → 0.1.5

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
  SHA1:
3
- metadata.gz: 56109898d2ab23df142c3b7417abcd03f064e245
4
- data.tar.gz: b8adaf8d1ec62008c9244b1a1b197a5da6b487d2
3
+ metadata.gz: ee8d2e66e30169da939693caa5428aaeafa891ad
4
+ data.tar.gz: e4052fffc46eb13cdc53103a7cee168bcc473100
5
5
  SHA512:
6
- metadata.gz: fca2133e2204b6645affb0705984ee073ceb399ef02dca03ac01785a4445c6a5223cf291a2ae5025c4d47055108b556f6082696ad43ae6b619c071d5e0c4a223
7
- data.tar.gz: 8105d267f95063a01bc72a0a749ee87320d3eb6ee56d7028afcd0124d5aaf9f9b797772f6e905774f07f96148fe2b2cfa8f946ffa93f24ed135ecdda5959ad1d
6
+ metadata.gz: d774f621e4f1510ac6aa47b21a21f645725a2a280b2ef8be830886deb657c115d822c0899cfe9e24bf78d0c50634d5e53f68d175004ba450de52e54c684da380
7
+ data.tar.gz: 999f6640564ffaf8e5898a8fa1bbd00098a32b6f722567344a510b1e666eed0aceec140663dc40730e1c468be2e18897ce650a401a765854d3c6549eb80a0182
@@ -43,22 +43,32 @@ module Vagrant
43
43
  # Get the SSH info for this machine so we can access it
44
44
  ssh_info = machine.ssh_info
45
45
 
46
- # Sync them!
47
- sync_threads = []
48
- folders.each do |id, folder_opts|
49
- sync_threads << Thread.new(id, folder_opts) do |id, folder_opts|
50
- ZscpHelper.scp(machine, ssh_info, folder_opts)
51
- end
46
+ # Clean up every synced folder first
47
+ foreach_folder(folders) do |folder_opts|
48
+ ZscpHelper.cleanup(machine, ssh_info, folder_opts)
52
49
  end
53
50
 
54
- sync_threads.each do |t|
55
- t.join
51
+ # Clean up every synced folder first
52
+ foreach_folder(folders) do |folder_opts|
53
+ ZscpHelper.scp(machine, ssh_info, folder_opts)
56
54
  end
57
55
  end
58
56
 
59
57
  return error ? 1 : 0
60
58
  end
59
+
60
+ def foreach_folder(folders, &block)
61
+ sync_threads = []
62
+ folders.each do |id, folder_opts|
63
+ sync_threads << Thread.new(folder_opts) do |folder_opts|
64
+ block.call(folder_opts)
65
+ end
66
+ end
67
+ sync_threads.each do |t|
68
+ t.join
69
+ end
70
+ end
61
71
  end
62
72
  end
63
73
  end
64
- end
74
+ end
@@ -3,11 +3,18 @@ module Vagrant
3
3
  # This is a helper that abstracts out the functionality of scping
4
4
  # folders so that it can be called from anywhere.
5
5
  class ZscpHelper
6
+ def self.cleanup(machine, ssh_info, opts)
7
+ guestpath = opts[:guestpath]
8
+ machine.ui.info("Removing remote #{guestpath}")
9
+ remotely_execute(ssh_info, "sudo rm -rf #{guestpath};")
10
+ end
11
+
6
12
  def self.scp(machine, ssh_info, opts)
7
13
  guestpath = opts[:guestpath]
8
- hostpath = opts[:hostpath]
9
- hostpath = File.expand_path(hostpath, machine.env.root_path)
14
+ hostpath = File.expand_path(opts[:hostpath], machine.env.root_path)
10
15
  hostpath = Vagrant::Util::Platform.fs_real_path(hostpath).to_s
16
+ hostpath += "/" if !hostpath.end_with?("/")
17
+
11
18
  if (opts[:zscp_include])
12
19
  included_files = opts[:zscp_include].join(' ')
13
20
  else
@@ -17,33 +24,27 @@ module Vagrant
17
24
  username = ssh_info[:username]
18
25
  host = ssh_info[:host]
19
26
 
20
- if !hostpath.end_with?("/")
21
- hostpath += "/"
22
- end
23
-
24
27
  machine.ui.info("Sending #{hostpath} to #{guestpath}")
25
- machine.ui.info("Removing remote #{guestpath}")
26
- remotely_execute(ssh_info, "sudo rm -rf #{guestpath}; sudo mkdir -p #{guestpath}; sudo chown #{username}:$(id -gn) #{guestpath}")
28
+ remotely_execute(ssh_info, "sudo mkdir -p #{guestpath}; sudo chown #{username}:$(id -gn #{username}) #{guestpath}")
27
29
 
28
- temp_file = `mktemp -t 'temp.XXXX.tar.gz'`.strip
30
+ temp_file = `mktemp -t 'temp.XXXX.tar.gz'`.strip
31
+ machine.ui.info("Compressing #{hostpath} into #{temp_file}")
32
+ system("tar -czhf #{temp_file} -C #{hostpath} #{included_files}")
29
33
 
30
- machine.ui.info("Compressing #{hostpath} into #{temp_file}")
31
- system("tar -czhf #{temp_file} -C #{hostpath} #{included_files}")
32
-
33
- machine.ui.info("Copying #{temp_file} to #{guestpath}")
34
- command = [
35
- "scp",
36
- '-o StrictHostKeyChecking=no',
37
- '-o UserKnownHostsFile=/dev/null',
38
- "-o port=#{ssh_info[:port]}",
39
- "-i '#{ssh_info[:private_key_path][0]}'",
40
- "#{temp_file}",
41
- "#{username}@#{host}:#{guestpath}"
42
- ].join(' ')
43
- system(command)
34
+ machine.ui.info("Copying #{temp_file} to #{guestpath}")
35
+ command = [
36
+ "scp",
37
+ '-o StrictHostKeyChecking=no',
38
+ '-o UserKnownHostsFile=/dev/null',
39
+ "-o port=#{ssh_info[:port]}",
40
+ "-i '#{ssh_info[:private_key_path][0]}'",
41
+ "#{temp_file}",
42
+ "#{username}@#{host}:#{guestpath}"
43
+ ].join(' ')
44
+ system(command)
44
45
 
45
- machine.ui.info("Extracting remotely #{guestpath}/temp.*.tar.gz")
46
- remotely_execute(ssh_info, "tar -xzf #{guestpath}/temp.*.tar.gz -C #{guestpath}; rm #{guestpath}/temp.*.tar.gz")
46
+ machine.ui.info("Extracting remotely #{guestpath}/temp.*.tar.gz")
47
+ remotely_execute(ssh_info, "tar -xzf #{guestpath}/temp.*.tar.gz -C #{guestpath}; rm #{guestpath}/temp.*.tar.gz")
47
48
  machine.ui.info("#{guestpath} synchronised")
48
49
  end
49
50
 
@@ -21,18 +21,27 @@ module Vagrant
21
21
  def enable(machine, folders, opts)
22
22
  ssh_info = machine.ssh_info
23
23
 
24
- folders.each do |id, folder_opts|
25
- sync_threads = []
26
- folders.each do |id, folder_opts|
27
- sync_threads << Thread.new(id, folder_opts) do |id, folder_opts|
28
- ZscpHelper.scp(machine, ssh_info, folder_opts)
29
- end
30
- end
24
+ # Clean up every synced folder first
25
+ foreach_folder(folders) do |folder_opts|
26
+ ZscpHelper.cleanup(machine, ssh_info, folder_opts)
27
+ end
28
+
29
+ # Clean up every synced folder first
30
+ foreach_folder(folders) do |folder_opts|
31
+ ZscpHelper.scp(machine, ssh_info, folder_opts)
32
+ end
33
+ end
31
34
 
32
- sync_threads.each do |t|
33
- t.join
35
+ def foreach_folder(folders, &block)
36
+ sync_threads = []
37
+ folders.each do |id, folder_opts|
38
+ sync_threads << Thread.new(folder_opts) do |folder_opts|
39
+ block.call(folder_opts)
34
40
  end
35
41
  end
42
+ sync_threads.each do |t|
43
+ t.join
44
+ end
36
45
  end
37
46
  end
38
47
  end
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Zscp
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-zscp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin Hebert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-06 00:00:00.000000000 Z
11
+ date: 2015-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler