upload_cache 1.4.0 → 1.4.1
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.
- data/lib/upload_cache.rb +21 -5
- data/upload_cache.gemspec +1 -1
- metadata +2 -2
data/lib/upload_cache.rb
CHANGED
@@ -5,7 +5,7 @@ require 'tmpdir'
|
|
5
5
|
require 'map'
|
6
6
|
|
7
7
|
class UploadCache
|
8
|
-
Version = '1.4.
|
8
|
+
Version = '1.4.1'
|
9
9
|
|
10
10
|
Readme = <<-__
|
11
11
|
NAME
|
@@ -64,7 +64,7 @@ class UploadCache
|
|
64
64
|
def url
|
65
65
|
@url ||= (
|
66
66
|
if defined?(Rails.root) and Rails.root
|
67
|
-
'/system/
|
67
|
+
'/system/upload_cache'
|
68
68
|
else
|
69
69
|
"file:/#{ root }"
|
70
70
|
end
|
@@ -202,12 +202,20 @@ class UploadCache
|
|
202
202
|
key = Array(options[:key] || args).flatten.compact
|
203
203
|
key = [:upload] if key.empty?
|
204
204
|
|
205
|
+
return(
|
206
|
+
currently_uploaded_file(params, key, options) or
|
207
|
+
previously_uploaded_file(params, key, options) or
|
208
|
+
default_uploaded_file(params, key, options)
|
209
|
+
)
|
210
|
+
end
|
211
|
+
|
212
|
+
def currently_uploaded_file(params, key, options)
|
205
213
|
upload = params.get(key)
|
206
214
|
|
207
215
|
if upload.respond_to?(:read)
|
208
216
|
tmpdir do |tmp|
|
209
217
|
original_basename =
|
210
|
-
[:
|
218
|
+
[:original_path, :original_filename, :path, :filename].
|
211
219
|
map{|msg| upload.send(msg) if upload.respond_to?(msg)}.compact.first
|
212
220
|
basename = cleanname(original_basename)
|
213
221
|
|
@@ -219,12 +227,16 @@ class UploadCache
|
|
219
227
|
end
|
220
228
|
end
|
221
229
|
|
230
|
+
false
|
231
|
+
end
|
232
|
+
|
233
|
+
def previously_uploaded_file(params, key, options)
|
222
234
|
cache_key = cache_key_for(key)
|
223
235
|
upload_cache = params.get(cache_key)
|
224
236
|
|
225
237
|
if upload_cache
|
226
|
-
dirname, basename = File.split(upload_cache)
|
227
|
-
relative_dirname = File.
|
238
|
+
dirname, basename = File.split(File.expand_path(upload_cache))
|
239
|
+
relative_dirname = File.basename(dirname)
|
228
240
|
relative_basename = File.join(relative_dirname, basename)
|
229
241
|
path = root + '/' + relative_basename
|
230
242
|
upload_cache = UploadCache.new(key, path, options)
|
@@ -232,6 +244,10 @@ class UploadCache
|
|
232
244
|
return upload_cache
|
233
245
|
end
|
234
246
|
|
247
|
+
false
|
248
|
+
end
|
249
|
+
|
250
|
+
def default_uploaded_file(params, key, options)
|
235
251
|
upload_cache = UploadCache.new(key, options)
|
236
252
|
params.set(key, upload_cache.io) if upload_cache.io
|
237
253
|
return upload_cache
|
data/upload_cache.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: upload_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-06 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'description: upload_cache kicks the ass'
|
15
15
|
email: ara.t.howard@gmail.com
|