File tree Expand file tree Collapse file tree 2 files changed +12
-22
lines changed
ui/console/command_dispatcher Expand file tree Collapse file tree 2 files changed +12
-22
lines changed Original file line number Diff line number Diff line change @@ -191,14 +191,6 @@ def type
191
191
end
192
192
193
193
def normalize ( value )
194
- if ( value =~ /^file:(.*)/ )
195
- path = $1
196
- begin
197
- value = File . read ( path )
198
- rescue ::Errno ::ENOENT , ::Errno ::EISDIR
199
- value = nil
200
- end
201
- end
202
194
value
203
195
end
204
196
@@ -220,14 +212,6 @@ def type
220
212
end
221
213
222
214
def normalize ( value )
223
- if ( value =~ /^file:(.*)/ )
224
- path = $1
225
- begin
226
- value = File . read ( path )
227
- rescue ::Errno ::ENOENT , ::Errno ::EISDIR
228
- value = nil
229
- end
230
- end
231
215
value
232
216
end
233
217
@@ -394,11 +378,7 @@ def type
394
378
395
379
def normalize ( value )
396
380
return nil unless value . kind_of? ( String )
397
- if ( value =~ /^file:(.*)/ )
398
- path = $1
399
- return false if not File . exists? ( path ) or File . directory? ( path )
400
- return File . readlines ( path ) . map { |s | s . strip } . join ( " " )
401
- elsif ( value =~ /^rand:(.*)/ )
381
+ if ( value =~ /^rand:(.*)/ )
402
382
count = $1. to_i
403
383
return false if count < 1
404
384
ret = ''
Original file line number Diff line number Diff line change @@ -806,7 +806,7 @@ def cmd_rename_job(*args)
806
806
end
807
807
808
808
# This is not respecting the Protected access control, but this seems to be the only way
809
- # to rename a job. If you know a more appropriate way, patches accepted.
809
+ # to rename a job. If you know a more appropriate way, patches accepted.
810
810
framework . jobs [ job_id ] . send ( :name= , job_name )
811
811
print_status ( "Job #{ job_id } updated" )
812
812
@@ -2068,6 +2068,16 @@ def cmd_set(*args)
2068
2068
return true
2069
2069
end
2070
2070
2071
+ # If the value starts with file: and exists, load the file as the value
2072
+ if value =~ /^file:(.*)/ && ::File . file? ( $1)
2073
+ fname = $1
2074
+ if ::File . size ( fname ) > ( 1024 *1024 )
2075
+ print_error ( "The file name specified is too big (over 1Mb)" )
2076
+ else
2077
+ ::File . open ( fname , "rb" ) { |fd | value = fd . read ( fd . stat . size ) }
2078
+ end
2079
+ end
2080
+
2071
2081
if append
2072
2082
datastore [ name ] = datastore [ name ] + value
2073
2083
else
You can’t perform that action at this time.
0 commit comments