else FileUtils.cp pkginfo_path, config_path end
if File.exist? data_path then
- # if os is linux, use cpio. it is faster than cp
- if Utils.is_linux_like_os( Utils::HOST_OS ) then
- absolute_path = `readlink -f #{target_path}`
- result = Utils.execute_shell_return("cd #{data_path}; find . -depth | cpio -pldm #{absolute_path}")
- else
- result = Utils.execute_shell_return("cp -r #{data_path}/* #{target_path}")
- end
- if result.nil? then
- logger.error "Failed to move files"
- logger.info " [from: #{source_path}]"
- logger.info " [to: #{target_path}]"
- return nil
+ if Dir.entries(data_path).count > 2 then
+ # if os is linux, use cpio. it is faster than cp
+ if Utils.is_linux_like_os( Utils::HOST_OS ) then
+ absolute_path = `readlink -f #{target_path}`
+ result = Utils.execute_shell_return("cd #{data_path}; find . -depth | cpio -pldm #{absolute_path}")
+ else
+ result = Utils.execute_shell_return("cp -r #{data_path}/* #{target_path}")
+ end
+ if result.nil? then
+ logger.error "Failed to move files"
+ logger.info " [from: #{source_path}]"
+ logger.info " [to: #{target_path}]"
+ return nil
+ end
+ logger.info "Moved files.. OK"
+ log = log + "[from: #{source_path}]\n"
+ log = log + "[to: #{target_path}]\n"
end
- logger.info "Moved files.. OK"
- log = log + "[from: #{source_path}]\n"
- log = log + "[to: #{target_path}]\n"
else logger.warn "\"data\" directory does not exist." end
return log