You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by lu...@redhat.com on 2012/12/03 08:54:09 UTC

[PATCH 3/3] Server: make sure we initialize the DB dir and the mock driver's data properly

From: David Lutterkort <lu...@redhat.com>

Server startup failed if /var/tmp/deltacloud-mock-$USER failed because the
DB initialization code did not create that directory. Creating that
directory fooled the logic in the mock driver that determined if the stock
data needed to be copied there.
---
 server/lib/db.rb                                  |    4 ++++
 server/lib/deltacloud/drivers/mock/mock_client.rb |    4 +---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/server/lib/db.rb b/server/lib/db.rb
index ac6d913..e6fe761 100644
--- a/server/lib/db.rb
+++ b/server/lib/db.rb
@@ -21,6 +21,10 @@ module Deltacloud
 
   def self.initialize_database
     DataMapper::Logger.new($stdout, :debug)
+    dbdir = File::dirname(DATABASE_LOCATION)
+    unless File::directory?(dbdir)
+      FileUtils::mkdir(dbdir)
+    end
     DataMapper::setup(:default, "sqlite://#{DATABASE_LOCATION}")
     DataMapper::finalize
     DataMapper::auto_upgrade!
diff --git a/server/lib/deltacloud/drivers/mock/mock_client.rb b/server/lib/deltacloud/drivers/mock/mock_client.rb
index c6dd464..919ee27 100644
--- a/server/lib/deltacloud/drivers/mock/mock_client.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_client.rb
@@ -26,9 +26,7 @@ module Deltacloud::Drivers::Mock
       @storage_root = storage_root
       @collections = []
 
-      if ! File::directory?(@storage_root)
-        FileUtils::rm_rf(@storage_root)
-        FileUtils::mkdir_p(@storage_root, :mode => 0750)
+      if ! File::directory?(File::join(@storage_root, "images"))
         data = Dir[File::join(File::dirname(__FILE__), "data", "*")]
         FileUtils::cp_r(data, @storage_root)
       end
-- 
1.7.7.6