fastlane-plugin-dropbox_upload 0.2.1 → 0.2.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d368238c2089c867dc14cb5a3599aeefb5887d46
|
4
|
+
data.tar.gz: 4f1b1f983d2921f07a4e42840b35da5fa94247df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2ed47e0a3e601f789f8962c7eb0628c5ba77159d11f6a6d34b796546d42db7bf09089d7039a0c0d93082e5af0cc5178e34981e3c9dc009897a70bbac58bfd3c
|
7
|
+
data.tar.gz: d384a1275712cc2a559677cc64df32c4fe00f8f4745fe1db518a935019efa8d87d77b56c7c3779cf162c887f3660bb16ddeab31f20148dac9d308d463fd481a5
|
@@ -12,6 +12,7 @@ module Fastlane
|
|
12
12
|
access_token = params[:access_token]
|
13
13
|
file_path = params[:file_path]
|
14
14
|
dropbox_path = params[:dropbox_path]
|
15
|
+
enable_clear = params[:enable_clear]
|
15
16
|
|
16
17
|
UI.message ''
|
17
18
|
UI.message("The dropbox_upload plugin is working!")
|
@@ -21,6 +22,9 @@ module Fastlane
|
|
21
22
|
if write_mode.nil?
|
22
23
|
write_mode = 'add'
|
23
24
|
end
|
25
|
+
if enable_clear.nil?
|
26
|
+
enable_clear = false
|
27
|
+
end
|
24
28
|
if write_mode.eql? 'update'
|
25
29
|
if update_rev.nil?
|
26
30
|
UI.user_error! 'You need to specify `update_rev` when using `update` write_mode.'
|
@@ -37,12 +41,14 @@ module Fastlane
|
|
37
41
|
|
38
42
|
client = DropboxApi::Client.new(access_token)
|
39
43
|
fileSize = File.size(file_path)
|
40
|
-
|
41
|
-
if
|
44
|
+
remain_space = is_space_enough(client, fileSize)
|
45
|
+
if remain_space >= 0
|
42
46
|
UI.message 'space is enough'
|
47
|
+
elsif enable_clear
|
48
|
+
UI.message "space almost fill need more #{-remain_space}, delete the earliest file"
|
49
|
+
delete_earliest_file(client, -remain_space)
|
43
50
|
else
|
44
|
-
UI.
|
45
|
-
delete_earliest_file(client, -more_space)
|
51
|
+
UI.user_error! "Can't to upload file to Dropbox, space is full!"
|
46
52
|
end
|
47
53
|
|
48
54
|
output_file = nil
|
@@ -126,15 +132,15 @@ module Fastlane
|
|
126
132
|
return unuse - fileSize
|
127
133
|
end
|
128
134
|
|
129
|
-
def self.delete_earliest_file(client,
|
135
|
+
def self.delete_earliest_file(client, space)
|
130
136
|
UI.message ''
|
131
|
-
UI.important "Need space #{
|
137
|
+
UI.important "Need space #{space}"
|
132
138
|
UI.message ''
|
133
139
|
delete_space = 0
|
134
140
|
files = get_all_files(client)
|
135
141
|
files.each { |file|
|
136
142
|
delete_space = delete_space + delete_file(client, file)
|
137
|
-
if delete_space >
|
143
|
+
if delete_space > space
|
138
144
|
break
|
139
145
|
end
|
140
146
|
}
|
@@ -153,7 +159,7 @@ module Fastlane
|
|
153
159
|
files.sort_by { |a|
|
154
160
|
a.client_modified
|
155
161
|
}
|
156
|
-
return files
|
162
|
+
return files.reverse
|
157
163
|
end
|
158
164
|
|
159
165
|
def self.list_folder(client, path = '')
|
@@ -212,7 +218,7 @@ module Fastlane
|
|
212
218
|
|
213
219
|
def self.available_options
|
214
220
|
[
|
215
|
-
|
221
|
+
FastlaneCore::ConfigItem.new(key: :file_path,
|
216
222
|
env_name: 'DROPBOX_FILE_PATH',
|
217
223
|
description: 'Path to the uploaded file',
|
218
224
|
type: String,
|
@@ -221,12 +227,12 @@ module Fastlane
|
|
221
227
|
UI.user_error!("No file path specified for upload to Dropbox, pass using `file_path: 'path_to_file'`") unless value && !value.empty?
|
222
228
|
UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value)
|
223
229
|
end),
|
224
|
-
|
230
|
+
FastlaneCore::ConfigItem.new(key: :dropbox_path,
|
225
231
|
env_name: 'DROPBOX_PATH',
|
226
232
|
description: 'Path to the destination Dropbox folder',
|
227
233
|
type: String,
|
228
234
|
optional: true),
|
229
|
-
|
235
|
+
FastlaneCore::ConfigItem.new(key: :write_mode,
|
230
236
|
env_name: 'DROPBOX_WRITE_MODE',
|
231
237
|
description: 'Determines uploaded file write mode. Supports `add`, `overwrite` and `update`',
|
232
238
|
type: String,
|
@@ -249,7 +255,13 @@ module Fastlane
|
|
249
255
|
optional: false,
|
250
256
|
verify_block: proc do |value|
|
251
257
|
UI.user_error!("access_token not specified for Dropbox app. Provide your app's access_token or create a new ") unless value && !value.empty?
|
252
|
-
end)
|
258
|
+
end),
|
259
|
+
FastlaneCore::ConfigItem.new(key: :enable_clear,
|
260
|
+
env_name: 'ENABLE_CLEAR',
|
261
|
+
description: 'enable delete file when space is full',
|
262
|
+
type: Boolean,
|
263
|
+
optional: true,
|
264
|
+
)
|
253
265
|
]
|
254
266
|
end
|
255
267
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-dropbox_upload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jason
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dropbox_api
|