OSDN Git Service

../shogi_server/game.rb: mkdir_p will be performed in a global mutex of ShogiServer...
authordaigo <beatles@users.sourceforge.jp>
Tue, 3 Aug 2010 13:21:09 +0000 (22:21 +0900)
committerDaigo Moriwaki <daigo@debian.org>
Tue, 3 Aug 2010 13:21:09 +0000 (22:21 +0900)
changelog
shogi_server/game.rb
test/TC_util.rb

index cc0a334..ca8194b 100644 (file)
--- a/changelog
+++ b/changelog
@@ -8,6 +8,8 @@
            now returns an instance correctly.
          - ../shogi_server.rb, ../shogi_server/util.rb: Refactored
            mkdir_for to Mkdir.mkdir_for.
            now returns an instance correctly.
          - ../shogi_server.rb, ../shogi_server/util.rb: Refactored
            mkdir_for to Mkdir.mkdir_for.
+         - ../shogi_server/game.rb: mkdir_p will be performed in a global
+           mutex of ShogiServer::Mkdir.
 
 2010-07-25  Daigo Moriwaki <daigo at debian dot org>
 
 
 2010-07-25  Daigo Moriwaki <daigo at debian dot org>
 
index c6b08e8..e6d58d9 100644 (file)
@@ -19,6 +19,7 @@
 
 require 'shogi_server/league/floodgate'
 require 'shogi_server/game_result'
 
 require 'shogi_server/league/floodgate'
 require 'shogi_server/game_result'
+require 'shogi_server/util'
 
 module ShogiServer # for a namespace
 
 
 module ShogiServer # for a namespace
 
@@ -71,8 +72,8 @@ class Game
                              @prepared_time.strftime("%Y"),
                              @prepared_time.strftime("%m"),
                              @prepared_time.strftime("%d"))
                              @prepared_time.strftime("%Y"),
                              @prepared_time.strftime("%m"),
                              @prepared_time.strftime("%d"))
-    FileUtils.mkdir_p(log_dir_name) unless File.exist?(log_dir_name)
     @logfile = File.join(log_dir_name, @game_id + ".csa")
     @logfile = File.join(log_dir_name, @game_id + ".csa")
+    Mkdir.mkdir_for(@logfile)
 
     $league.games[@game_id] = self
 
 
     $league.games[@game_id] = self
 
index fcdae10..79ac945 100644 (file)
@@ -56,4 +56,8 @@ class TestMkdir < Test::Unit::TestCase
     assert FileTest.directory?(File.dirname(@test_dir))
   end
 
     assert FileTest.directory?(File.dirname(@test_dir))
   end
 
+  def test_dirname
+    assert_equal "/hoge", File.dirname("/hoge/foo")
+  end
+
 end
 end