From 4b6712b74d9db8eaa53f511a4a8ccc758c528afe Mon Sep 17 00:00:00 2001
From: Eric Rasmussen <eric@unl.edu>
Date: Fri, 10 Sep 2010 00:01:50 +0000
Subject: [PATCH] Fix some of the warnings that come up in the migration tool:
 urldecode url before looking the file up on frontier, suppress warnings
 (duplicate dir was the problem) coming from mkdir, make sure there's a '/'
 between ftp base and path before getting modified time

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x@157 20a16fea-79d4-4915-8869-1ea9d5ebf173
---
 sites/all/modules/unl/unl_migration.php | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/sites/all/modules/unl/unl_migration.php b/sites/all/modules/unl/unl_migration.php
index 300838ab..2f157ec6 100644
--- a/sites/all/modules/unl/unl_migration.php
+++ b/sites/all/modules/unl/unl_migration.php
@@ -110,7 +110,7 @@ class Unl_Migration_Tool
         $this->_baseUrl = $baseUrl;
         $this->_addSitePath('');
         $this->_curl = curl_init();
-        $this->_frontierScan();
+        $this->_frontierScan('/');
     }
     
     private function _migrate()
@@ -198,7 +198,7 @@ class Unl_Migration_Tool
     
         $linkNodes = $navlinksNode->getElementsByTagName('a');
         foreach ($linkNodes as $linkNode) {
-            $this->_processLinks($linkNode->getAttribute('href'), $path);
+            $this->_processLinks($linkNode->getAttribute('href'), '');
         }
         
         $navlinksUlNode = $navlinksNode->getElementsByTagName('ul')->item(0);
@@ -342,7 +342,7 @@ class Unl_Migration_Tool
                 $this->_log('The file type at ' . $fullPath . ' was not specified. Ignoring.');
                 return;
             }
-            drupal_mkdir('public://' . dirname($path), NULL, TRUE);
+            @drupal_mkdir('public://' . dirname($path), NULL, TRUE);
             $file = file_save_data($data['content'], 'public://' . $path, FILE_EXISTS_REPLACE);
             $this->_hrefTransformFiles[$path] = file_directory_path() . '/' . $path;
             return;
@@ -598,7 +598,15 @@ class Unl_Migration_Tool
             return NULL;
         }
         
-        $ftpPath = $this->_frontierPath . substr($url, strlen($this->_baseUrl));
+        //Don't want url encoded chars like %20 in ftp file path 
+        $url = urldecode($url);
+        
+        $path = substr($url, strlen($this->_baseUrl));
+        if ($path[0] != '/') {
+            $path = '/'.$path;
+        }
+        
+        $ftpPath = $this->_frontierPath . $path;
         if (substr($ftpPath, -1) == '/') {
             $ftpPath .= 'index.shtml';
         }
-- 
GitLab