winrm-fs 1.3.4 → 1.3.5
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 +4 -4
- data/lib/winrm-fs.rb +2 -2
- data/lib/winrm-fs/core/file_transporter.rb +9 -5
- data/lib/winrm-fs/core/tmp_zip.rb +4 -4
- data/lib/winrm-fs/file_manager.rb +21 -8
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22197843455d6d73e34d00c91fd58d4a6201d08f02f61a64d5b971085360aebf
|
4
|
+
data.tar.gz: fd9181f9187df12ad0a6812891c29a1e917ccfc9f2d4064448a52d08f0455d05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebf3f8d594d00219a5b19f6eb2ba17ae4f466de4d4eb0929b6f61f8f9075473ccdaff127ab3ed10a06280a309cfe3b5d8976a1857970c3f02a22080413690667
|
7
|
+
data.tar.gz: a56cf8645bcb803c377f7146a1c5a005496e74b9b7993b6f18f38dd70c2a4de00174c65cd7abc3a0e409b07fa10a10bab7fce145b5dfb6991744f2c720d9a2e0
|
data/lib/winrm-fs.rb
CHANGED
@@ -15,9 +15,9 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
|
-
require 'winrm'
|
18
|
+
require 'winrm' unless defined?(WinRM::Connection)
|
19
19
|
require 'logger'
|
20
|
-
require 'pathname'
|
20
|
+
require 'pathname' unless defined?(Pathname)
|
21
21
|
require_relative 'winrm-fs/exceptions'
|
22
22
|
require_relative 'winrm-fs/file_manager'
|
23
23
|
|
@@ -17,11 +17,11 @@
|
|
17
17
|
# See the License for the specific language governing permissions and
|
18
18
|
# limitations under the License.
|
19
19
|
|
20
|
-
require 'benchmark'
|
21
|
-
require 'csv'
|
22
|
-
require 'digest'
|
23
|
-
require 'securerandom'
|
24
|
-
require 'stringio'
|
20
|
+
require 'benchmark' unless defined?(Benchmark)
|
21
|
+
require 'csv' unless defined?(CSV)
|
22
|
+
require 'digest' unless defined?(Digest)
|
23
|
+
require 'securerandom' unless defined?(SecureRandom)
|
24
|
+
require 'stringio' unless defined?(StringIO)
|
25
25
|
|
26
26
|
require 'winrm/exceptions'
|
27
27
|
require 'winrm-fs/core/tmp_zip'
|
@@ -117,6 +117,10 @@ module WinRM
|
|
117
117
|
[total_size, files]
|
118
118
|
end
|
119
119
|
|
120
|
+
def close
|
121
|
+
shell.close
|
122
|
+
end
|
123
|
+
|
120
124
|
private
|
121
125
|
|
122
126
|
# @return [String] the Array pack template for Base64 encoding a stream
|
@@ -18,9 +18,9 @@
|
|
18
18
|
# limitations under the License.
|
19
19
|
|
20
20
|
require 'delegate'
|
21
|
-
require 'pathname'
|
22
|
-
require 'tempfile'
|
23
|
-
require 'zip'
|
21
|
+
require 'pathname' unless defined?(Pathname)
|
22
|
+
require 'tempfile' unless defined?(Tempfile)
|
23
|
+
require 'zip' unless defined?(Zip)
|
24
24
|
|
25
25
|
module WinRM
|
26
26
|
module FS
|
@@ -113,7 +113,7 @@ module WinRM
|
|
113
113
|
# directory, excluding directories
|
114
114
|
# @api private
|
115
115
|
def entries
|
116
|
-
Pathname.glob(dir.join('**/*')).delete_if(&:directory?).sort
|
116
|
+
Pathname.glob(dir.join('**/.*')).push(*Pathname.glob(dir.join('**/*'))).delete_if(&:directory?).sort
|
117
117
|
end
|
118
118
|
|
119
119
|
# (see Logging.log_subject)
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
|
-
require 'winrm'
|
18
|
+
require 'winrm' unless defined?(WinRM::Connection)
|
19
19
|
require_relative 'scripts/scripts'
|
20
20
|
require_relative 'core/file_transporter'
|
21
21
|
|
@@ -37,7 +37,7 @@ module WinRM
|
|
37
37
|
def checksum(path, digest = 'SHA1')
|
38
38
|
@logger.debug("checksum with #{digest}: #{path}")
|
39
39
|
script = WinRM::FS::Scripts.render('checksum', path: path, digest: digest)
|
40
|
-
|
40
|
+
ps_run(script).exitcode == 0
|
41
41
|
end
|
42
42
|
|
43
43
|
# Create the specifed directory recursively
|
@@ -46,7 +46,7 @@ module WinRM
|
|
46
46
|
def create_dir(path)
|
47
47
|
@logger.debug("create_dir: #{path}")
|
48
48
|
script = WinRM::FS::Scripts.render('create_dir', path: path)
|
49
|
-
|
49
|
+
ps_run(script).exitcode == 0
|
50
50
|
end
|
51
51
|
|
52
52
|
# Deletes the file or directory at the specified path
|
@@ -55,7 +55,7 @@ module WinRM
|
|
55
55
|
def delete(path)
|
56
56
|
@logger.debug("deleting: #{path}")
|
57
57
|
script = WinRM::FS::Scripts.render('delete', path: path)
|
58
|
-
|
58
|
+
ps_run(script).exitcode == 0
|
59
59
|
end
|
60
60
|
|
61
61
|
# Downloads the specified remote file to the specified local path
|
@@ -87,7 +87,7 @@ module WinRM
|
|
87
87
|
|
88
88
|
def _output_from_file(remote_path, chunk_size, index)
|
89
89
|
script = WinRM::FS::Scripts.render('download', path: remote_path, chunk_size: chunk_size, index: index)
|
90
|
-
|
90
|
+
ps_run(script)
|
91
91
|
end
|
92
92
|
|
93
93
|
def _write_file(tofd, output)
|
@@ -106,7 +106,7 @@ module WinRM
|
|
106
106
|
def exists?(path)
|
107
107
|
@logger.debug("exists?: #{path}")
|
108
108
|
script = WinRM::FS::Scripts.render('exists', path: path)
|
109
|
-
|
109
|
+
ps_run(script).exitcode == 0
|
110
110
|
end
|
111
111
|
|
112
112
|
# Gets the current user's TEMP directory on the remote system, for example
|
@@ -114,7 +114,7 @@ module WinRM
|
|
114
114
|
# @return [String] Full path to the temp directory
|
115
115
|
def temp_dir
|
116
116
|
@temp_dir ||= begin
|
117
|
-
(
|
117
|
+
ps_run('$env:TEMP').stdout.chomp.tr('\\', '/')
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
@@ -139,12 +139,25 @@ module WinRM
|
|
139
139
|
def upload(local_path, remote_path, &block)
|
140
140
|
@connection.shell(:powershell) do |shell|
|
141
141
|
file_transporter ||= WinRM::FS::Core::FileTransporter.new(shell)
|
142
|
-
|
142
|
+
begin
|
143
|
+
file_transporter.upload(local_path, remote_path, &block)[0]
|
144
|
+
ensure
|
145
|
+
file_transporter.close
|
146
|
+
end
|
143
147
|
end
|
144
148
|
end
|
145
149
|
|
146
150
|
private
|
147
151
|
|
152
|
+
def ps_run(cmd)
|
153
|
+
shell = @connection.shell(:powershell)
|
154
|
+
begin
|
155
|
+
shell.run(cmd)
|
156
|
+
ensure
|
157
|
+
shell.close
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
148
161
|
def download_dir(remote_path, local_path, chunk_size, first)
|
149
162
|
local_path = File.join(local_path, File.basename(remote_path.to_s)) if first
|
150
163
|
FileUtils.mkdir_p(local_path) unless File.directory?(local_path)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: winrm-fs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shawn Neal
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-09-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: erubi
|
@@ -185,8 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '0'
|
187
187
|
requirements: []
|
188
|
-
|
189
|
-
rubygems_version: 2.7.8
|
188
|
+
rubygems_version: 3.1.2
|
190
189
|
signing_key:
|
191
190
|
specification_version: 4
|
192
191
|
summary: WinRM File System
|