diff --git a/stage_file_proxy.module b/stage_file_proxy.module
index 64b74d5..b93cd64 100644
--- a/stage_file_proxy.module
+++ b/stage_file_proxy.module
@@ -56,6 +56,9 @@ function _stage_file_proxy_fetch($server, $relative_path) {
   foreach ($dirs as $dir) {
     $tree[] = $dir;
     $dir_path = $file_dir . '/' . implode('/', $tree);
+    if (!file_check_directory($dir_path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
+      return FALSE;
+    }
   }
   $url = $server . '/' . $dir_path . '/' . rawurlencode($filename);
   $ch = curl_init($url);
@@ -64,10 +67,8 @@ function _stage_file_proxy_fetch($server, $relative_path) {
   curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15');
   $res = curl_exec($ch);
   if (curl_getinfo($ch, CURLINFO_HTTP_CODE) < 300) {
-    if (file_check_directory($file_dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
-      file_put_contents($file_dir . '/' . $relative_path, $res);
-      return TRUE;
-    }
+    file_put_contents($file_dir . '/' . $relative_path, $res);
+    return TRUE;
   }
   return FALSE;
 }
