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: d3125d437d27ef16ee2c54448771e36b4020ba6f
4
- data.tar.gz: a0c44590d99b07192439737e8b4b24347b7f8c40
3
+ metadata.gz: d368238c2089c867dc14cb5a3599aeefb5887d46
4
+ data.tar.gz: 4f1b1f983d2921f07a4e42840b35da5fa94247df
5
5
  SHA512:
6
- metadata.gz: 8f28511356f7d3208fa36abae71442333547e77766c820a657819ef2c75a2121627c0bdd2677bd8dd76cc5a1b01a3c16d7ab51fffc761568622462fb0fdcd5ec
7
- data.tar.gz: 79a3f03044697f63340e29db2199acc0f494352db9b9bcb322fcff5592c4aa3423997c8e5ce0288642727dd5be3a24ff15481cc350a45584809162290a028e9d
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
- more_space = is_space_enough(client, fileSize)
41
- if more_space >= 0
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.message "space almost fill need more #{-more_space}, delete the earliest file"
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, more_space)
135
+ def self.delete_earliest_file(client, space)
130
136
  UI.message ''
131
- UI.important "Need space #{more_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 > more_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
- FastlaneCore::ConfigItem.new(key: :file_path,
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
- FastlaneCore::ConfigItem.new(key: :dropbox_path,
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
- FastlaneCore::ConfigItem.new(key: :write_mode,
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
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module DropboxUpload
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
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.1
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-18 00:00:00.000000000 Z
11
+ date: 2019-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dropbox_api