rbbt-rest 1.2.8 → 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/rbbt/rest/file_server.rb +23 -10
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzkxNzcyYjE0ZmRjYTFiMGJjZDI4ZGY3N2Y0OTVjMWU1ZDdkZjc0Yg==
4
+ MWFhMmFjMWFjYzU4Njg2ODYyYWRkY2NkMjNmYWFiMGQ3NmZkYjBkZA==
5
5
  data.tar.gz: !binary |-
6
- MzQ0ODc5Y2M2ZjFlOWUzYjViMmY5ZjZiNmJjNDAwZjA2MDgyODJjNw==
6
+ N2RhYmYyYmI2Njg5YTE3YTZhYzkyNDg1OWMzNzc2NzgyYzVjZmQ4NA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTA1NWNiYzI0MWRmNWU3OTRlYWYyY2Y0M2Y2MTNlODk1MTc5ZjhkNDI3ZDRk
10
- N2JkNzkzNDhjZTVlZTgyOWY5NzE2MGI5YWZmN2VhMmE5YTFjMDQxZDE5YTgx
11
- YzExNmNkZDE3YjEyMWNlMzFhMmNjZGIxN2JkZDJlYWNjNTU2Nzc=
9
+ ZDk0MDczNTUxNGNhMTY2NzM3YjBmNDc3YjYzNGFiODZhYWI4MjdjMzVkZDQ0
10
+ NDIzYzA4YWJhMDAwNjU0ZWEzZGU5MTI4MmE0MWViOGNkOWJlNGMwM2JjYWRi
11
+ YmJlNTQ2ZGMwZjA1ODg5M2U2ZmY1MTljMGU1ZWFjMGE0NjJmMzY=
12
12
  data.tar.gz: !binary |-
13
- ZWRkMWFlNDBiZGJmYmMxMmIxMDdmYmY1YWE0MDIwYjY1OTljODk3NTI3ODQ3
14
- YzVmZjMxOTcwNjU5MzcwYTIyMzgyZjdlYmJmMjk1MDJkYmQ0ZjQyMDViZmJl
15
- MjFkYWZiOWNjZWI1NDZmMzI2YzcwZjkyOWQ3ZGU5MDY5OTBkM2U=
13
+ YWExOWJmODJiMDNkZmNlNjAyOTcxZGQxYjAxYjQ4OWIzMTk1YjAzMTNiYzhi
14
+ NjNhZDhiMTlmNTFmYzFmYzcwMjI1ZmEzZWIyNzdmMjUxODNhMzFmNmZhYjM3
15
+ MDgxOTE3ODQwYWNjMWE2M2YzMDA4NjJlNzE5MTUwZjNhZGY0YmQ=
@@ -16,6 +16,8 @@ module Sinatra
16
16
 
17
17
  resource = Kernel.const_get(resource)
18
18
 
19
+ directory = $1 if resource.subdir and directory =~ /^#{resource.subdir}\/?(.*)/
20
+
19
21
  path = resource.root[directory]
20
22
 
21
23
  raise "For security reasons the file path must not leave the resource root directory" unless Misc.path_relative_to(resource.root, path)
@@ -25,15 +27,24 @@ module Sinatra
25
27
  raise "Directory does not exist" unless path.exists? or create
26
28
  raise "Directory does not exist and can not create it" unless path.exists? or path.produce.exists?
27
29
 
28
- stream(:binmode => true) do |out|
29
-
30
- io = Misc.in_dir path.find do
31
- CMD.cmd("tar cfz - '.'", :pipe => true)
32
- end
33
-
34
- while not io.closed? and block = io.read(4096)
35
- out << block
30
+ #stream do |out|
31
+ # io = nil
32
+ # Misc.in_dir path.find do
33
+ # io = CMD.cmd("tar cfvz - '.'", :pipe => true)
34
+ # end
35
+ # while not io.closed? and block = io.read(4096)
36
+ # out << block
37
+ # end
38
+ # io.close
39
+ # out.flush
40
+ #end
41
+
42
+ TmpFile.with_file :extension => 'tar.gz' do |file|
43
+ Misc.in_dir path.find do
44
+ CMD.cmd("tar cfvz '#{file}' .")
36
45
  end
46
+ headers['Content-Encoding'] = 'gzip'
47
+ send_file file, :filename => directory.gsub('/','_') + '.tar.gz', :type => "application/x-gzip"
37
48
  end
38
49
  end
39
50
 
@@ -54,8 +65,10 @@ module Sinatra
54
65
 
55
66
  Log.debug("Resource: #{[resource, file, path, path.find] * " | "}")
56
67
 
57
- raise "File does not exist" unless path.exists? or create
58
- raise "File does not exist and can not create it" unless path.exists? or path.produce.exists?
68
+ raise "File does not exist and can not create it" unless path.exists?
69
+
70
+ directory_url = File.join("/resource", resource.to_s , 'get_directory') << '?' << "create=#{create}" << '&' << "directory=#{file}"
71
+ redirect to(directory_url) if path.directory?
59
72
 
60
73
  send_file path.find, :filename => path
61
74
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.8
4
+ version: 1.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-06 00:00:00.000000000 Z
11
+ date: 2013-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake