paperclip-storage-ftp 1.2.5 → 1.2.6

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: 06f6f8ed2f5e20bde0739d480b35b1db12b02181
4
- data.tar.gz: 151088832a19d13b6d8d2747f072c61867d7eba4
3
+ metadata.gz: 52dd89bd22677f466873efbf00464db5185f89e7
4
+ data.tar.gz: cc7bf20e77a50e009cf45b2feca86c311d3451aa
5
5
  SHA512:
6
- metadata.gz: 2ed88432200631ef634da8f80bc881f1926fcd00a833b8c034d639821da686f2bd5688f7283c38216fa6db1921ee2e37504a2a7ee5c15f5ab4cc3ba885bab852
7
- data.tar.gz: 1bb9d03ff4bcc716cac6b28714d704f837e7c7cf4daab10005acec4b2fcb2eb9fde861a0b5f21a1cd024e54c7cdb649e7557932ee7e71db74f3ccbdf6a5cf40b
6
+ metadata.gz: 854d6376410b4c7e7dbed7d0ad0ecc35aa349c2974618aeef3340c4795e0bcc1a237c68dd4dae433a559cfd69b85860afdd63618dd8cf459c91355dbe9d57eb5
7
+ data.tar.gz: 7463b456f29a1bc116a4ff64ae34626a90c9682e043f6c3046c613ad7e8d8c6053c833eaee6c466330873e64cc593fccc9beda548a225b052505be4fcb48af5a
data/README.md CHANGED
@@ -77,13 +77,21 @@ class User < ActiveRecord::Base
77
77
  # not be uploaded to that server.
78
78
  # If set to false and the connection to a particular server cannot be established,
79
79
  # a SystemCallError will be raised (Errno::ETIMEDOUT, Errno::ENETUNREACH, etc.).
80
- :ftp_ignore_failing_connections => true # optional, false by default
80
+ :ftp_ignore_failing_connections => true, # optional, false by default
81
+
82
+ # Optional flag to keep empty parent directories when deleting files.
83
+ :ftp_keep_empty_directories => true # optional, false by default
81
84
  }
82
85
  end
83
86
  ```
84
87
 
85
88
  ## Changelog
86
89
 
90
+ ### 1.2.6
91
+
92
+ * New option `:ftp_keep_empty_directories` to disable the removal of empty parent directories when deleting files (introduced in 1.2.2). See usage example above.
93
+ * Fix missing log lines in logjam. This only affects apps that use [logjam_agent](https://github.com/skaes/logjam_agent).
94
+
87
95
  ### 1.2.5
88
96
 
89
97
  * Ignore ftp error when deleting an non-existing file [#29](https://github.com/xing/paperclip-storage-ftp/pull/29)
@@ -38,7 +38,7 @@ module Paperclip
38
38
  unless @queued_for_write.empty?
39
39
  with_ftp_servers do |servers|
40
40
  servers.map do |server|
41
- Thread.new do
41
+ run_thread do
42
42
  @queued_for_write.each do |style_name, file|
43
43
  remote_path = path(style_name)
44
44
  log("saving ftp://#{server.user}@#{server.host}:#{remote_path}")
@@ -58,11 +58,11 @@ module Paperclip
58
58
  unless @queued_for_delete.empty?
59
59
  with_ftp_servers do |servers|
60
60
  servers.map do |server|
61
- Thread.new do
61
+ run_thread do
62
62
  @queued_for_delete.each do |path|
63
63
  log("deleting ftp://#{server.user}@#{server.host}:#{path}")
64
64
  server.delete_file(path)
65
-
65
+ next if @options[:ftp_keep_empty_directories]
66
66
  log("deleting empty parent directories ftp://#{server.user}@#{server.host}:#{path}")
67
67
  server.rmdir_p(File.dirname(path))
68
68
  end
@@ -123,6 +123,22 @@ module Paperclip
123
123
  server.establish_connection
124
124
  server
125
125
  end
126
+
127
+ private
128
+
129
+ if defined?(LogjamAgent)
130
+ def run_thread(&blk)
131
+ request = LogjamAgent.request
132
+ Thread.new do
133
+ LogjamAgent.request = request
134
+ blk.call
135
+ end
136
+ end
137
+ else
138
+ def run_thread(&blk)
139
+ Thread.new(&blk)
140
+ end
141
+ end
126
142
  end
127
143
  end
128
144
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
13
  gem.name = "paperclip-storage-ftp"
14
14
  gem.require_paths = ["lib"]
15
- gem.version = "1.2.5"
15
+ gem.version = "1.2.6"
16
16
 
17
17
  gem.add_dependency("paperclip")
18
18
 
@@ -66,6 +66,17 @@ describe "paperclip-storage-ftp", :integration => true do
66
66
  Dir.exist?(File.dirname(uploaded_file_server2)).should be false
67
67
  end
68
68
 
69
+ it "does not remove empty parent directories if disabled" do
70
+ user = UserDisablingEmptyDirectoryRemoval.new
71
+ user.avatar = file
72
+ user.save!
73
+
74
+ user.destroy
75
+
76
+ Dir.exist?(File.dirname(uploaded_file_server1)).should be true
77
+ Dir.exist?(File.dirname(uploaded_file_server2)).should be true
78
+ end
79
+
69
80
  it "does not remove parent directories which are not empty" do
70
81
  user.avatar = file
71
82
  user.save!
@@ -99,3 +99,9 @@ class UserNotIgnoringFailingConnection < UserWithInvalidPort
99
99
  :ftp_ignore_failing_connections => false
100
100
  ))
101
101
  end
102
+
103
+ class UserDisablingEmptyDirectoryRemoval < User
104
+ setup_avatar_attachment(avatar_options.merge(
105
+ :ftp_keep_empty_directories => true
106
+ ))
107
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-storage-ftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Röbke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-21 00:00:00.000000000 Z
11
+ date: 2015-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: paperclip