# File lib/fastcst/changeset.rb, line 124
124:         def detect_moved_files
125:             md5sums = {}  # use as a reverse lookup
126:         
127:             del_basenames = index_base_names(@deleted)
128:             tgt_basenames = index_base_names(@created)
129:             
130:             del_basenames.each do |basename, files|
131:                 # we only process files that have unique locations mentioned, this is a direct possible move
132:                 tgt_files = tgt_basenames[basename]
133:                 if tgt_files && tgt_files.length == 1 && files.length == 1
134:                     del_digest = ""
135:                     tgt_digest = ""
136:                     from_file = files[0]
137:                     to_file = tgt_files[0]
138:                     
139:                     # next test is to simply compare files sizes, can't be same file if different size
140:                     if File.size?(@source + '/' + from_file) == File.size?(@target + '/' + to_file)
141:                         
142:                         # now generate the hashes for both files as the final confirmation of same file
143:                         Dir.chdir(@source) { del_digest = Digest::MD5.digest(File.read(from_file)) }
144:                         Dir.chdir(@target) { tgt_digest = Digest::MD5.digest(File.read(to_file)) }
145:                         
146:                         if del_digest == tgt_digest
147:                             # digests match so the basenames are the same and the digests are the same, it's a move
148:                             @moved[from_file] = [to_file, File.stat(File.join(@target,to_file)).mtime]
149:                             
150:                             # and clean the files from either side to eliminate them
151:                             @deleted.delete from_file
152:                             @created.delete to_file
153:                         end
154:                     end
155:                 end
156:             end
157:         end