Method: FileUtils::FileUtils.unify_time

Defined in:
lib/file_utils/file_utils.rb

.unify_time(content_data) ⇒ Object

then the assumption is that this file wasnt indexized and it will not be treated

(e.i. we do nothing with it)


164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/file_utils/file_utils.rb', line 164

def self.unify_time(content_data)
  orig_content_data = ContentData::ContentData.new(content_data)
  content_data.unify_time
  content_data.each_instance { |checksum, size, content_mod_time, unified_inst_mod_time, server, path|
    location = [server, path]
    orig_inst_mod_time = orig_content_data.get_instance_mod_time(checksum, location)
    file_mtime, file_size = File.open(path) { |f| [f.mtime, f.size] }
    Log.debug1 "file:#{path} file_mtime:#{file_mtime}."
    Log.debug1 "update mtime:#{unified_inst_mod_time}"
    Log.debug1 "original instance mtime:#{orig_inst_mod_time}."
    Log.debug1 "unify instance mtime:#{unified_inst_mod_time}."
    Log.debug1 "Comparison: Real file = unified? #{file_mtime.to_i == unified_inst_mod_time}"
    if (file_mtime.to_i == orig_inst_mod_time) \
          and file_size == size \
          and (file_mtime.to_i != unified_inst_mod_time)
      Log.debug1 ("Comparison results: File actual time is same as instance time before unification. Need to modify file time")
      File.utime(File.atime(path), unified_inst_mod_time, path)
      file_mtime = File.open(path) { |f| f.mtime }
      Log.debug1 "new file mtime:#{file_mtime}."
      Log.debug1 "new file mtime in seconds:#{file_mtime.to_i}."
    end
  }
  content_data
end