rsite 0.0.1 → 0.0.2
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/bin/rsite-cli +37 -3
- data/lib/rsite/utils.rb +29 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f57e145a94a0c4d0de17b9204a8ec2b589d77234
|
4
|
+
data.tar.gz: 6b30a9ea86271bf0decef3eaa42e064c578440d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5573a4a723a4f52cedb1c9575d24d140de59047fa30c85f10f622adba76e5796f1eeb4c7efb19a71ae2c0bb548ae1fdaa565fb29a926590264e58fb56b31143
|
7
|
+
data.tar.gz: 74a31d0cbfa0041ce9c6984467537f1bf99fa4df34f400f2dd7ee4a458ea6f34d38ff5abbdf55ee5743e2441944b5acf19a25d3f09804dd2e43267a9d70f7a78
|
data/bin/rsite-cli
CHANGED
@@ -38,6 +38,21 @@ opts = OptionParser.new do |opts|
|
|
38
38
|
options[:full] = s
|
39
39
|
end
|
40
40
|
|
41
|
+
opts.on("-g", "--gen sitename",
|
42
|
+
"Generates key pair for you") do |u|
|
43
|
+
options[:gen] = u
|
44
|
+
end
|
45
|
+
|
46
|
+
opts.on("-t", "--two-part",
|
47
|
+
"Two part upload") do |s|
|
48
|
+
options[:two] = s
|
49
|
+
end
|
50
|
+
|
51
|
+
opts.on("-r", "--first-run",
|
52
|
+
"alternative first run options") do |s|
|
53
|
+
options[:first] = s
|
54
|
+
end
|
55
|
+
|
41
56
|
opts.on("-s", "--save",
|
42
57
|
"Save your current insert options for directory") do |s|
|
43
58
|
options[:save] = s
|
@@ -68,10 +83,25 @@ else
|
|
68
83
|
end
|
69
84
|
|
70
85
|
client = FCPClient.new("rsite-#{SecureRandom.hex}", host, port)
|
71
|
-
|
72
|
-
if options.has_key? :path and File.directory? options[:path].chomp.lstrip
|
86
|
+
if options.has_key? :path
|
73
87
|
path = options[:path].chomp.lstrip
|
88
|
+
else
|
89
|
+
path = Dir.pwd
|
90
|
+
end
|
91
|
+
|
92
|
+
if options.has_key? :gen
|
93
|
+
uris = client.new_ssk_pair().pop
|
94
|
+
name = options[:gen].chomp.lstrip
|
95
|
+
options[:uri] = 'U' + uris["InsertURI"][1..-1] + name + "/0/"
|
96
|
+
options[:ouri] = 'U' + uris["RequestURI"][1..-1] + name + "/0/"
|
97
|
+
end
|
98
|
+
|
99
|
+
if File.directory? path
|
100
|
+
|
74
101
|
rsite = RSUtils.new(path)
|
102
|
+
if options[:first]
|
103
|
+
rsite.firstrun = true
|
104
|
+
end
|
75
105
|
unless options.has_key? :uri
|
76
106
|
if File.exist? File.join(path,'.inserturi')
|
77
107
|
options[:uri] = YAML::load(File.read( File.join path, '.inserturi'))
|
@@ -107,7 +137,11 @@ if options.has_key? :path and File.directory? options[:path].chomp.lstrip
|
|
107
137
|
puts "You need a request uri either in .uri of this path or specified by option -o"
|
108
138
|
end
|
109
139
|
end
|
110
|
-
|
140
|
+
if options[:two]
|
141
|
+
(rsite.twopart_upload).each do |x|
|
142
|
+
rsite.current[x] = client.simple_put('CHK@',rsite.current[x]).pop['URI']
|
143
|
+
end
|
144
|
+
end
|
111
145
|
if options[:full]
|
112
146
|
response = client.simple_dir_put(uri, path, {"DefaultName" => options[:index]}).pop
|
113
147
|
elsif options.has_key? :ouri
|
data/lib/rsite/utils.rb
CHANGED
@@ -6,8 +6,8 @@ require 'optparse'
|
|
6
6
|
|
7
7
|
class RSUtils
|
8
8
|
|
9
|
-
attr_reader :
|
10
|
-
attr_accessor :client, :version
|
9
|
+
attr_reader :path
|
10
|
+
attr_accessor :client, :version, :current, :firstrun
|
11
11
|
|
12
12
|
def initialize(path)
|
13
13
|
@filehashfilepath = File.join(path,'.filehashes')
|
@@ -16,6 +16,7 @@ class RSUtils
|
|
16
16
|
@path = path
|
17
17
|
@current ={}
|
18
18
|
@version = 0
|
19
|
+
@firstrun = false
|
19
20
|
directory_hash
|
20
21
|
end
|
21
22
|
|
@@ -35,9 +36,13 @@ class RSUtils
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def files_to_update
|
38
|
-
last = YAML::load(File.read(@filehashfilepath))
|
39
|
-
@version = last[0] if @version == 0
|
40
|
-
@
|
39
|
+
last = YAML::load(File.read(@filehashfilepath)) unless @firstrun
|
40
|
+
@version = last[0] if @version == 0 unless @firstrun
|
41
|
+
if @firstrun
|
42
|
+
@current.keys
|
43
|
+
else
|
44
|
+
@current.keys - last[1].keys
|
45
|
+
end
|
41
46
|
end
|
42
47
|
|
43
48
|
def save_uris(uri,ouri)
|
@@ -62,8 +67,23 @@ class RSUtils
|
|
62
67
|
return updateables
|
63
68
|
else
|
64
69
|
puts "Perform full upload to initialize the directory for use"
|
65
|
-
|
70
|
+
if @firstrun
|
71
|
+
updateables = files_to_update
|
72
|
+
return updateables
|
73
|
+
else
|
74
|
+
return []
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def twopart_upload
|
80
|
+
largerfiles = []
|
81
|
+
@current.each_key do |u|
|
82
|
+
if (File.size @current[u]) > 1048576
|
83
|
+
largerfiles << u
|
84
|
+
end
|
66
85
|
end
|
86
|
+
largerfiles
|
67
87
|
end
|
68
88
|
|
69
89
|
def format_file_list(updateable,uri)
|
@@ -73,7 +93,8 @@ class RSUtils
|
|
73
93
|
name = @current[u].sub @path, ''
|
74
94
|
name.sub! '\\' '/' if File::SEPARATOR == '\\'
|
75
95
|
name = name[1..-1] if name[0] == '/'
|
76
|
-
file = {name: name, uploadfrom: 'disk', filename: @current[u]}
|
96
|
+
file = {name: name, uploadfrom: 'disk', filename: @current[u]} unless @current[u] =~ /^CHK@/
|
97
|
+
file = {name: @current[u].split('/')[-1], uploadfrom: 'redirect', targeturi: @current[u]} if @current[u] =~ /^CHK@/
|
77
98
|
files.push file
|
78
99
|
end
|
79
100
|
end
|
@@ -85,6 +106,7 @@ class RSUtils
|
|
85
106
|
ssk = uri.split '@'
|
86
107
|
ssk = 'SSK@'+(ssk[1].split('/')[0...-1].join('/'))+"-#{@version}/"+name
|
87
108
|
file = {name: name, uploadfrom: 'redirect', targeturi: ssk}
|
109
|
+
file = {name: @current[u].split('/')[-1], uploadfrom: 'redirect', targeturi: @current[u]} if @current[u] =~ /^CHK@/
|
88
110
|
files.push file
|
89
111
|
end
|
90
112
|
end
|