backup_foundation 0.9.3 → 0.9.4
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/backup_foundation/job.rb +28 -12
- data/lib/backup_foundation/version.rb +1 -1
- 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: e551a2d3dc0da1b02e9aeac46bf78a2d1c8a4a9c
|
|
4
|
+
data.tar.gz: 20d5efee61d05ffc931bf90bb6ca2cd67b914d10
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dac1c3cc89dc62c847758ff79531a04994e692d8b8c8e0aa62394da655f8c0134308784973dd9cd91aa95308b95014f8b4b54ea7374a3d98d770955f98404892
|
|
7
|
+
data.tar.gz: ffaf1f2ed65ff213fcaebff6b2dcf92c36818ecce7e15ad9f4833d5bf54274084518641051537c2dcbbc3a3860c11469f804d8bc3ea27f3c2ad4cf38c9c52a99
|
|
@@ -65,23 +65,39 @@ module BackupFoundation
|
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
def download_db_dump(tmpdir, db)
|
|
68
|
+
def download_db_dump(tmpdir, db, limit = 10)
|
|
69
69
|
file_path = nil
|
|
70
|
-
url = URI.parse
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
url = URI.parse case db
|
|
71
|
+
when Hash
|
|
72
|
+
"#{BackupFoundation::HOST}/api/file?key=#{@params[:key]}&name=#{db[:name] || db[:type]}"
|
|
73
|
+
when String
|
|
74
|
+
db
|
|
75
75
|
end
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
http_download_request(url).request_get(url.request_uri) do |response|
|
|
77
|
+
case response
|
|
78
|
+
when Net::HTTPSuccess
|
|
79
|
+
file_path = "#{tmpdir}/#{(response['Content-Disposition'] || "\"#{url.path.split('/').last}\"")[/"(.*)"/, 1]}"
|
|
80
|
+
File.open file_path, 'wb' do |file|
|
|
81
|
+
response.read_body do |str|
|
|
82
|
+
file.write str
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
when Net::HTTPRedirection
|
|
86
|
+
file_path = download_db_dump(tmpdir, response['Location'], limit - 1)
|
|
87
|
+
else
|
|
88
|
+
response.error!
|
|
82
89
|
end
|
|
83
90
|
end
|
|
84
91
|
file_path
|
|
85
92
|
end
|
|
93
|
+
|
|
94
|
+
def http_download_request(url)
|
|
95
|
+
Net::HTTP.new(url.host, url.port).tap do |http|
|
|
96
|
+
if url.is_a? URI::HTTPS
|
|
97
|
+
http.use_ssl = true
|
|
98
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
86
102
|
end
|
|
87
103
|
end
|