files.com 1.1.672 → 1.1.673
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/_VERSION +1 -1
- data/lib/files.com/models/file.rb +67 -0
- data/lib/files.com/path_util.rb +1 -1
- data/lib/files.com/version.rb +1 -1
- data/shared/normalization_for_comparison_test_data.json +3 -1
- data/spec/models/file_underscore_destinations_spec.rb +24 -0
- data/spec/path_util_spec.rb +5 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2c0f447b5e7b8543176cf0015a4faeb255fa1dcbcbc851c99c315ae8790ec10c
|
|
4
|
+
data.tar.gz: 84cbfcdb04f041ee2f8066c5ae5ce20f0976cfd50ef025541a0601d083b87dac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a13395a04d8e6610d4270134ef6dfd441f60e4649f276781593b41048b61b3ebd6fda4f1ca7cca53be0f03851ffcc70c1b40ff5b3139cb546a56baca2b22a002
|
|
7
|
+
data.tar.gz: 000737fb292996b739973ede951603d43b19548f80c4bbca286c8ee12f2730341c298f3532624c3f782f33e683000748178ba31dd8239f215ce025eb65033de6
|
data/_VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.1.
|
|
1
|
+
1.1.673
|
|
@@ -38,6 +38,49 @@ module Files
|
|
|
38
38
|
new(path).download_file(local_path)
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
+
private_class_method def self.underscore_destination_path(root, id, relative_path = nil)
|
|
42
|
+
PathUtil.normalize("_", root, id.to_s, relative_path)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.upload_to_remote_server(path, remote_server_id, destination = nil, options = {}, params: {})
|
|
46
|
+
destination ||= ::File.basename(path)
|
|
47
|
+
upload_file(path, underscore_destination_path("RemoteServers", remote_server_id, destination), options, params: params)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.copy_to_remote_server(path, remote_server_id, destination, params = {}, options = {})
|
|
51
|
+
copy(path, params.merge(destination: underscore_destination_path("RemoteServers", remote_server_id, destination)), options)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def self.move_to_remote_server(path, remote_server_id, destination, params = {}, options = {})
|
|
55
|
+
move(path, params.merge(destination: underscore_destination_path("RemoteServers", remote_server_id, destination)), options)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def self.upload_to_snapshot(path, snapshot_id, destination = nil, options = {}, params: {})
|
|
59
|
+
destination ||= ::File.basename(path)
|
|
60
|
+
upload_file(path, underscore_destination_path("Snapshots", snapshot_id, destination), options, params: params)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def self.copy_to_snapshot(path, snapshot_id, destination, params = {}, options = {})
|
|
64
|
+
copy(path, params.merge(destination: underscore_destination_path("Snapshots", snapshot_id, destination)), options)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def self.move_to_snapshot(path, snapshot_id, destination, params = {}, options = {})
|
|
68
|
+
move(path, params.merge(destination: underscore_destination_path("Snapshots", snapshot_id, destination)), options)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def self.upload_to_child_site(path, site_id, destination = nil, options = {}, params: {})
|
|
72
|
+
destination ||= ::File.basename(path)
|
|
73
|
+
upload_file(path, underscore_destination_path("Sites", site_id, destination), options, params: params)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def self.copy_to_child_site(path, site_id, destination, params = {}, options = {})
|
|
77
|
+
copy(path, params.merge(destination: underscore_destination_path("Sites", site_id, destination)), options)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def self.move_to_child_site(path, site_id, destination, params = {}, options = {})
|
|
81
|
+
move(path, params.merge(destination: underscore_destination_path("Sites", site_id, destination)), options)
|
|
82
|
+
end
|
|
83
|
+
|
|
41
84
|
def self.exist?(path, options = {})
|
|
42
85
|
find(path, {}, options)
|
|
43
86
|
true
|
|
@@ -187,6 +230,30 @@ module Files
|
|
|
187
230
|
@bytes_written = 0
|
|
188
231
|
end
|
|
189
232
|
|
|
233
|
+
def copy_to_remote_server(remote_server_id, destination, params = {})
|
|
234
|
+
self.class.copy_to_remote_server(path, remote_server_id, destination, params, @options)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
def move_to_remote_server(remote_server_id, destination, params = {})
|
|
238
|
+
self.class.move_to_remote_server(path, remote_server_id, destination, params, @options)
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
def copy_to_snapshot(snapshot_id, destination, params = {})
|
|
242
|
+
self.class.copy_to_snapshot(path, snapshot_id, destination, params, @options)
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
def move_to_snapshot(snapshot_id, destination, params = {})
|
|
246
|
+
self.class.move_to_snapshot(path, snapshot_id, destination, params, @options)
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
def copy_to_child_site(site_id, destination, params = {})
|
|
250
|
+
self.class.copy_to_child_site(path, site_id, destination, params, @options)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def move_to_child_site(site_id, destination, params = {})
|
|
254
|
+
self.class.move_to_child_site(path, site_id, destination, params, @options)
|
|
255
|
+
end
|
|
256
|
+
|
|
190
257
|
def advise(*_args); end
|
|
191
258
|
|
|
192
259
|
def atime
|
data/lib/files.com/path_util.rb
CHANGED
|
@@ -21,7 +21,7 @@ module Files
|
|
|
21
21
|
new_path
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
def self.normalize(*paths)
|
|
25
25
|
all_paths = paths.flatten.compact.map { |path| u8(path).gsub("\x00", "").gsub("\\", "/").split("/") }.flatten
|
|
26
26
|
all_paths.map { |path| cleanpath(path) }.reject(&:empty?).join("/")
|
|
27
27
|
end
|
data/lib/files.com/version.rb
CHANGED
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
[ "invalid_null_byte_before\u0000after", "invalid_null_byte_beforeafter" ],
|
|
24
24
|
[ "a/b/c/../../hello", "a/b/c/hello" ],
|
|
25
25
|
[ "a/b/c/././hello", "a/b/c/hello" ],
|
|
26
|
+
[ "remote/../path/to/file.txt", "remote/path/to/file.txt" ],
|
|
27
|
+
[ "/../../remote\\path//./to/file.txt", "remote/path/to/file.txt" ],
|
|
26
28
|
[ "one_code_point_ą", "one_code_point_a" ],
|
|
27
29
|
[ "two_code_points_ą", "two_code_points_a" ],
|
|
28
30
|
[ "one_code_point_훯", "one_code_point_훯"],
|
|
@@ -46,4 +48,4 @@
|
|
|
46
48
|
[ "../.", ""],
|
|
47
49
|
[ "./../.", "" ],
|
|
48
50
|
[ ".././..", ""]
|
|
49
|
-
]
|
|
51
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
RSpec.describe Files::File do
|
|
4
|
+
it "copies to a remote server underscore destination" do
|
|
5
|
+
expect(described_class).to receive(:copy).with(
|
|
6
|
+
"source.txt",
|
|
7
|
+
{ overwrite: true, destination: "_/RemoteServers/42/remote/path/to/file.txt" },
|
|
8
|
+
{}
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
described_class.copy_to_remote_server("source.txt", 42, "/../../remote\\path//./to/file.txt", { overwrite: true })
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "uploads to a remote server underscore destination using the local basename" do
|
|
15
|
+
expect(described_class).to receive(:upload_file).with(
|
|
16
|
+
"local/path/to/file.txt",
|
|
17
|
+
"_/RemoteServers/42/file.txt",
|
|
18
|
+
{},
|
|
19
|
+
params: {}
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
described_class.upload_to_remote_server("local/path/to/file.txt", 42)
|
|
23
|
+
end
|
|
24
|
+
end
|
data/spec/path_util_spec.rb
CHANGED
|
@@ -11,4 +11,9 @@ RSpec.describe Files::PathUtil do
|
|
|
11
11
|
expect(Files::PathUtil.same?(src_chars, dst_chars)).to eq(true)
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
|
+
|
|
15
|
+
it "normalizes API paths without changing path identity" do
|
|
16
|
+
expect(Files::PathUtil.normalize("/../../remote\\path//./to/file.txt")).to eq("remote/path/to/file.txt")
|
|
17
|
+
expect(Files::PathUtil.normalize("remote/../path/to/file.txt")).to eq("remote/path/to/file.txt")
|
|
18
|
+
end
|
|
14
19
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: files.com
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.673
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- files.com
|
|
@@ -469,6 +469,7 @@ files:
|
|
|
469
469
|
- spec/lib/api_client_spec.rb
|
|
470
470
|
- spec/list_spec.rb
|
|
471
471
|
- spec/models/file_spec.rb
|
|
472
|
+
- spec/models/file_underscore_destinations_spec.rb
|
|
472
473
|
- spec/models/folder_spec.rb
|
|
473
474
|
- spec/path_util_spec.rb
|
|
474
475
|
- spec/spec_helper.rb
|