Method: LENSE#stage

Defined in:
lib/lense.rb

#stage(file) ⇒ Object



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/lense.rb', line 208

def stage(file)
  if File.file?(file)
    dependency = get_dependency(file)
    if dependency.nil?
      should_stage = true
    else
      current_hash = hash_file(file)

      # is it modified?
      if dependency[:file_hash] == current_hash
        should_stage = false
      else
        should_stage = true
      end
    end

    if should_stage
      begin
        @DB.transaction
        @DB.execute "insert into staging (path) values (?);", file
        @DB.commit
      rescue
      end
    end
  end
end