Skip to content

Instantly share code, notes, and snippets.

@danlynn
Created June 30, 2010 03:02
Show Gist options
  • Select an option

  • Save danlynn/458176 to your computer and use it in GitHub Desktop.

Select an option

Save danlynn/458176 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'pathname'
require 'lib/database_utils'
DatabaseUtils.establish_connection
puts "--- Scanning filesystem to add missing files to db ---"
puts " Total java files in db before sync = #{Source.count}"
filesystem_src_count = 0
Pathname.new($config["root_src_dir"]).find do |f|
if f.extname == ".java"
Source.create_from_pathname(f) unless Source.find(:first, :conditions => ["path = ?", f])
filesystem_src_count += 1
puts " #{filesystem_src_count} files" if filesystem_src_count % 100 == 0
end
end
puts " Total java files in db after sync = #{Source.count}"
puts " Total java files scanned = #{filesystem_src_count}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment