Make sure the userData directory is created before ready event
authorCheng Zhao <zcbenz@gmail.com>
Fri, 29 Apr 2016 11:20:52 +0000 (20:20 +0900)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 29 Apr 2016 11:20:52 +0000 (20:20 +0900)
atom/browser/browser.cc

index b3c7a59..093209e 100644 (file)
@@ -9,7 +9,10 @@
 #include "atom/browser/atom_browser_main_parts.h"
 #include "atom/browser/native_window.h"
 #include "atom/browser/window_list.h"
+#include "base/files/file_util.h"
 #include "base/message_loop/message_loop.h"
+#include "base/path_service.h"
+#include "brightray/browser/brightray_paths.h"
 
 namespace atom {
 
@@ -139,6 +142,11 @@ void Browser::WillFinishLaunching() {
 }
 
 void Browser::DidFinishLaunching() {
+  // Make sure the userData directory is created.
+  base::FilePath user_data;
+  if (PathService::Get(brightray::DIR_USER_DATA, &user_data))
+    base::CreateDirectoryAndGetError(user_data, nullptr);
+
   is_ready_ = true;
   FOR_EACH_OBSERVER(BrowserObserver, observers_, OnFinishLaunching());
 }