Commit 904b0ac

mo khan <mo@mokhan.ca>
2015-02-04 05:39:13
add scan task to blast a bunch of queries against the server.
1 parent 5b4c048
Changed files (1)
lib
lib/tasks/scan.rake
@@ -0,0 +1,17 @@
+namespace :scan do
+  desc "scan all files"
+  task dir: :environment do
+    require 'net/http'
+
+    agent = Agent.first
+    Dir['**/**/*'].each do |file|
+      if File.file?(file)
+        result = `shasum -a 256 #{file}`
+        sha = result.split(' ').first
+
+        uri = URI("http://localhost:3000/agents/#{agent.id}/files/#{sha}")
+        puts [sha, Net::HTTP.get(uri)].inspect
+      end
+    end
+  end
+end