rbbt-rest 1.2.23 → 1.2.24
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 +8 -8
- data/lib/rbbt/rest/file_server.rb +24 -17
- data/share/views/public/js/rbbt/modal.js +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjViNDIyYjJhNjdkYmE3MTllNjJkN2I4YTRjZTI4NWNlYmQ0NDY4YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGMxNjc1NjI2ODdlNzhlNDM1NTQyY2E4NTgxMzdlZjQ4NTc1NTcxMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjIzZmVhZmU0ZTEzYTU3ZmI4ZDI0YzA0M2Q2ZDZmNTY3NjEzYmM2NmZhYzVh
|
10
|
+
ZmFlZWI3ZWEzNDFiYzc5NTQzNTljZjM3Njg0ODRmNjk3ODU4MmVmMDliNDFh
|
11
|
+
M2U0OGM1M2UxZDVlYTE3ZDEwMjQzYTljY2U4N2Q5ZTQxZDZjY2Q=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTQwM2U5NzAwZDY4MDBmYzlkYWVjOTRlYmJhYTgwNzhiZmRmZDJjM2IxYjRl
|
14
|
+
MTAwZWIyZTZjY2M2ZDRjZmMwZmM4M2Y5ODljMWE2NmMwN2I4Y2FmM2YzMzAx
|
15
|
+
ZDI2M2JmYThiMmY1YjlmYjEwMDcwNmIwY2Y3MDBiZDEzMTA1ZDQ=
|
@@ -1,11 +1,14 @@
|
|
1
1
|
require 'rbbt'
|
2
2
|
require 'sinatra/base'
|
3
|
+
require 'sinatra/streaming'
|
4
|
+
|
3
5
|
|
4
6
|
module Sinatra
|
5
7
|
module RbbtRESTFileServer
|
6
8
|
|
7
9
|
def self.registered(base)
|
8
10
|
base.module_eval do
|
11
|
+
helpers Sinatra::Streaming
|
9
12
|
|
10
13
|
get '/resource/:resource/get_directory' do
|
11
14
|
directory, resource, create = params.values_at :directory, :resource, :create
|
@@ -27,24 +30,28 @@ module Sinatra
|
|
27
30
|
raise "Directory does not exist" unless path.exists? or create
|
28
31
|
raise "Directory does not exist and can not create it" unless path.exists? or path.produce.exists?
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
33
|
+
headers['Content-Encoding'] = 'gzip'
|
34
|
+
chunk_size = 1024
|
35
|
+
stream do |out|
|
36
|
+
tar = Misc.tarize(path.find)
|
37
|
+
|
38
|
+
out.errback do
|
39
|
+
Log.error{"Error streaming #{ path }"}
|
40
|
+
begin tar.close unless tar.closed?; rescue; end
|
41
|
+
out.close unless out.closed?
|
42
|
+
end
|
43
|
+
|
44
|
+
begin
|
45
|
+
while chunk = tar.read(1024)
|
46
|
+
out << chunk
|
47
|
+
end
|
48
|
+
ensure
|
49
|
+
Log.debug("Finished streaming #{path}. Closing")
|
50
|
+
begin tar.close unless tar.closed?; rescue; end
|
51
|
+
out.close unless out.closed?
|
45
52
|
end
|
46
|
-
|
47
|
-
|
53
|
+
|
54
|
+
out
|
48
55
|
end
|
49
56
|
end
|
50
57
|
|