276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
|
# File 'lib/dao/upload.rb', line 276
def process_currently_uploaded(io)
unless @tmpdir
@tmpdir = Upload.tmpdir
end
original_basename =
[:original_path, :original_filename, :path, :filename, :pathname].
map{|msg| io.send(msg).to_s if io.respond_to?(msg)}.
compact.
first
basename = Upload.cleanname(original_basename)
path = File.join(@tmpdir, basename)
copied = false
Upload.rewind(io) do
src = Upload.path_for(io)
dst = path
strategies = [
proc{ `ln -f #{ src.inspect } #{ dst.inspect } || cp -f #{ src.inspect } #{ dst.inspect }`},
proc{ FileUtils.ln(src, dst) },
proc{ FileUtils.cp(src, dst) },
proc{
open(dst, 'wb'){|fd| fd.write(io.read)}
}
]
FileUtils.rm_f(dst)
strategies.each do |strategy|
strategy.call rescue nil
break if((copied = test(?e, dst)))
end
end
raise("failed to copy #{ io.path.inspect } -> #{ path.inspect }") unless copied
gcopen(path) if test(?s, path)
end
|