lib/qdumpfs/util.rb in qdumpfs-1.6.0 vs lib/qdumpfs/util.rb in qdumpfs-1.6.1

- old
+ new

@@ -33,11 +33,12 @@ def self.force_symlink(src, dest) begin File.unlink(dest) if File.anything_exist?(dest) File.symlink(src, dest) - rescue + rescue + puts "force_symlink fails #{src} #{dest}" end end def self.force_link(src, dest) File.unlink(dest) if File.anything_exist?(dest) @@ -63,23 +64,23 @@ module QdumpfsFind def find(logger, *paths) block_given? or return enum_for(__method__, *paths) paths.collect!{|d| - raise Errno::ENOENT unless File.exist?(d); + raise Errno::ENOENT unless File.exist?(d) d.dup } - while file = paths.shift + while (file = paths.shift) catch(:prune) do yield file.dup.taint begin s = File.lstat(file) rescue => e logger.print("File.lstat path=#{file} error=#{e.message}") next end - if s.directory? then + if s.directory? begin fs = Dir.entries(file, :encoding=>'UTF-8') rescue => e logger.print("Dir.entries path=#{file} error=#{e.message}") next @@ -118,12 +119,14 @@ i += 1 @write_bytes += block.size end } } - rescue EOFError => e - # puts e.message, e.backtrace + rescue EOFError + # この実装だとファイルサイズがblock_sizeより小さい場合にEOFErrorが発生する + # それはしかたがないので無視する + # puts e.message end unless FileTest.file?(dest) raise "copy_file fails #{dest}" end end @@ -192,10 +195,10 @@ case File.ftype(src) when "file" type = "new_file" when "link" type = "symlink" - end + end end end return type end