olek-paperclipftp 0.1.0.7 → 0.1.0.8
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/VERSION +1 -1
- data/lib/paperclipftp.rb +25 -17
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.0.
|
1
|
+
0.1.0.8
|
data/lib/paperclipftp.rb
CHANGED
@@ -14,17 +14,6 @@ module Paperclip
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def ftp
|
18
|
-
if @ftp.nil? || @ftp.closed?
|
19
|
-
Timeout::timeout(@timeout, FtpTimeout) do
|
20
|
-
@ftp = Net::FTP.new(@ftp_credentials[:host], @ftp_credentials[:username], @ftp_credentials[:password])
|
21
|
-
@ftp.debug_mode = @debug_mode
|
22
|
-
@ftp.passive = @passive_mode
|
23
|
-
end
|
24
|
-
end
|
25
|
-
@ftp
|
26
|
-
end
|
27
|
-
|
28
17
|
def exists?(style = default_style)
|
29
18
|
Timeout::timeout(@timeout, FtpTimeout) do
|
30
19
|
file_size(ftp_path(style)) > 0
|
@@ -55,7 +44,7 @@ module Paperclip
|
|
55
44
|
rescue Net::FTPPermError => e
|
56
45
|
if first_try
|
57
46
|
first_try = false
|
58
|
-
|
47
|
+
create_parent_folder_for(remote_path)
|
59
48
|
retry
|
60
49
|
else
|
61
50
|
raise e
|
@@ -75,7 +64,7 @@ module Paperclip
|
|
75
64
|
rescue Net::FTPPermError => e
|
76
65
|
raise e
|
77
66
|
ensure
|
78
|
-
|
67
|
+
close_ftp_connection
|
79
68
|
end
|
80
69
|
|
81
70
|
def flush_deletes
|
@@ -94,12 +83,30 @@ module Paperclip
|
|
94
83
|
rescue Net::FTPPermError => e
|
95
84
|
raise e
|
96
85
|
ensure
|
97
|
-
|
86
|
+
close_ftp_connection
|
98
87
|
end
|
99
88
|
|
100
89
|
private
|
101
90
|
|
102
|
-
def
|
91
|
+
def ftp
|
92
|
+
if @ftp.nil? || @ftp.closed?
|
93
|
+
Timeout::timeout(@timeout, FtpTimeout) do
|
94
|
+
@ftp = Net::FTP.new(@ftp_credentials[:host], @ftp_credentials[:username], @ftp_credentials[:password])
|
95
|
+
@ftp.debug_mode = @debug_mode
|
96
|
+
@ftp.passive = @passive_mode
|
97
|
+
end
|
98
|
+
end
|
99
|
+
@ftp
|
100
|
+
end
|
101
|
+
|
102
|
+
def close_ftp_connection
|
103
|
+
unless @ftp.nil? || @ftp.closed?
|
104
|
+
@ftp.close
|
105
|
+
@ftp = nil
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def create_parent_folder_for(remote_path)
|
103
110
|
dir_path = File.dirname(remote_path)
|
104
111
|
ftp.chdir("/")
|
105
112
|
dir_path.split(File::SEPARATOR).each do |rdir|
|
@@ -120,7 +127,8 @@ module Paperclip
|
|
120
127
|
end
|
121
128
|
|
122
129
|
def ftp_path(style)
|
123
|
-
|
130
|
+
path = path(style)
|
131
|
+
path.nil? ? nil : '/' + path
|
124
132
|
end
|
125
133
|
|
126
134
|
def file_size(remote_path)
|
@@ -129,7 +137,7 @@ module Paperclip
|
|
129
137
|
#File not exists
|
130
138
|
-1
|
131
139
|
rescue Net::FTPReplyError => e
|
132
|
-
|
140
|
+
close_ftp_connection
|
133
141
|
raise e
|
134
142
|
end
|
135
143
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: olek-paperclipftp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 87
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
9
|
- 0
|
10
|
-
-
|
11
|
-
version: 0.1.0.
|
10
|
+
- 8
|
11
|
+
version: 0.1.0.8
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Damian Caruso
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-05-
|
19
|
+
date: 2011-05-12 00:00:00 -04:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|