knife-essentials 0.7 → 0.7.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.
@@ -98,7 +98,8 @@ module ChefFS
98
98
  found_result = false
99
99
  list_pairs(pattern, src_root, dest_root) do |src, dest|
100
100
  found_result = true
101
- copy_entries(src, dest, recurse_depth, options)
101
+ new_dest_parent = get_or_create_parent(dest, options)
102
+ copy_entries(src, dest, new_dest_parent, recurse_depth, options)
102
103
  end
103
104
  if !found_result && pattern.exact_path
104
105
  puts "#{pattern}: No such file or directory on remote or local"
@@ -196,7 +197,7 @@ module ChefFS
196
197
  private
197
198
 
198
199
  # Copy two entries (could be files or dirs)
199
- def self.copy_entries(src_entry, dest_entry, recurse_depth, options)
200
+ def self.copy_entries(src_entry, dest_entry, new_dest_parent, recurse_depth, options)
200
201
  # A NOTE about this algorithm:
201
202
  # There are cases where this algorithm does too many network requests.
202
203
  # knife upload with a specific filename will first check if the file
@@ -224,28 +225,27 @@ module ChefFS
224
225
  end
225
226
 
226
227
  elsif !dest_entry.exists?
227
- dest_parent = get_or_create_parent(dest_entry, options)
228
- if dest_parent.can_have_child?(src_entry.name, src_entry.dir?)
228
+ if new_dest_parent.can_have_child?(src_entry.name, src_entry.dir?)
229
229
  if src_entry.dir?
230
230
  if options[:dry_run]
231
231
  puts "Would create #{dest_entry.path_for_printing}"
232
- new_dest_dir = dest_parent.child(src_entry.name)
232
+ new_dest_dir = new_dest_parent.child(src_entry.name)
233
233
  else
234
- new_dest_dir = dest_parent.create_child(src_entry.name, nil)
234
+ new_dest_dir = new_dest_parent.create_child(src_entry.name, nil)
235
235
  puts "Created #{dest_entry.path_for_printing}/"
236
236
  end
237
237
  # Directory creation is recursive.
238
238
  if recurse_depth != 0
239
239
  src_entry.children.each do |src_child|
240
240
  new_dest_child = new_dest_dir.child(src_child.name)
241
- copy_entries(src_child, new_dest_child, recurse_depth ? recurse_depth - 1 : recurse_depth, options)
241
+ copy_entries(src_child, new_dest_child, new_dest_dir, recurse_depth ? recurse_depth - 1 : recurse_depth, options)
242
242
  end
243
243
  end
244
244
  else
245
245
  if options[:dry_run]
246
246
  puts "Would create #{dest_entry.path_for_printing}"
247
247
  else
248
- dest_entry.parent.create_child(src_entry.name, src_entry.read)
248
+ new_dest_parent.create_child(src_entry.name, src_entry.read)
249
249
  puts "Created #{dest_entry.path_for_printing}"
250
250
  end
251
251
  end
@@ -274,7 +274,7 @@ module ChefFS
274
274
  # If both are directories, recurse into their children
275
275
  if recurse_depth != 0
276
276
  child_pairs(src_entry, dest_entry).each do |src_child, dest_child|
277
- copy_entries(src_child, dest_child, recurse_depth ? recurse_depth - 1 : recurse_depth, options)
277
+ copy_entries(src_child, dest_child, dest_entry, recurse_depth ? recurse_depth - 1 : recurse_depth, options)
278
278
  end
279
279
  end
280
280
  else
@@ -314,7 +314,9 @@ module ChefFS
314
314
  parent = entry.parent
315
315
  if !parent.exists?
316
316
  parent_parent = get_or_create_parent(entry.parent, options)
317
- if !options[:dry_run]
317
+ if options[:dry_run]
318
+ puts "Would create #{parent.path_for_printing}"
319
+ else
318
320
  parent = parent_parent.create_child(parent.name, true)
319
321
  puts "Created #{parent.path_for_printing}"
320
322
  end
@@ -1,4 +1,4 @@
1
1
  module ChefFS
2
- VERSION = "0.7"
2
+ VERSION = "0.7.1"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-essentials
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.7'
4
+ version: 0.7.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: