Browse files

add flocking to converter driver

  • Loading branch information...
1 parent 42a0d9f commit 0d443a713d511fb21b028fe162423dda1a10efa6 @smparkes smparkes committed Apr 21, 2010
Showing with 13 additions and 2 deletions.
  1. +3 −2 .gitignore
  2. +10 −0 app/models/video_converter.rb
View
5 .gitignore
@@ -13,6 +13,7 @@
/vendor/gems/*/ext/*/*.so
/vendor/gems/*/lib/*.so
/vendor/gems/*/ext/redcloth_scan/*.o
-/lib/KFQuilt
+/lib/ovsurgen
/ovdlt.tgz
-/pkg
+/pkg
+/tmp/vc.lock
View
10 app/models/video_converter.rb
@@ -3,6 +3,16 @@ class VideoConverter
class << self
def run directory = nil
+ if !File.exist? "tmp/vc.lock"
+ system "touch tmp/vc.lock"
+ end
+ f = File.open "tmp/vc.lock"
+ result = f.flock File::LOCK_EX | File::LOCK_NB
+ if !result
+ $stderr.print "lock already taken: exiting\n"
+ exit
+ end
+
directories = nil
if !directory.blank?
# FIX for windows if we keep this

0 comments on commit 0d443a7

Please sign in to comment.