Author: david
Date: Fri Sep  2 17:09:06 2011
New Revision: 9658

Log:
Incomplete.  Cant move first sub-directory of uploads when migrating digital 
objects to repo directory.

Modified:
   trunk/lib/task/migrate/QubitMigrate110.class.php

Modified: trunk/lib/task/migrate/QubitMigrate110.class.php
==============================================================================
--- trunk/lib/task/migrate/QubitMigrate110.class.php    Fri Sep  2 16:37:58 
2011        (r9657)
+++ trunk/lib/task/migrate/QubitMigrate110.class.php    Fri Sep  2 17:09:06 
2011        (r9658)
@@ -660,19 +660,32 @@
             continue;
           }
 
-          // Move entire info object directory (e.g. 'uploads/3/1/318/' to 
-          // 'uploads/r/repo-name/3/1/318')
-          $old = substr($item2['path'], 0, 10); // e.g. '/uploads/3'
-          $new = str_replace('uploads', 'uploads/r/'.$repo['slug'], $old);
+          $oldpath = rtrim($item2['path'], '/');
 
-          if (file_exists(sfConfig::get('sf_web_dir').$old))
+          // Build new path
+          if (preg_match('|/(\d)/(\d)/\d{3,}|', $item2['path'], $matches))
           {
-            if (!rename(sfConfig::get('sf_web_dir').$old, 
sfConfig::get('sf_web_dir').$new))
+            mkdir($newpath = 
sfConfig::get('sf_upload_dir').'/r/'.$repo['slug'].'/'.$matches[1]);
+            mkdir($newpath .= '/'.$matches[2]);
+          }
+          else
+          {
+            continue;
+          }
+
+          if (file_exists(sfConfig::get('sf_web_dir').$item2['path']))
+          {
+            if (!rename(sfConfig::get('sf_web_dir').$item2['path'], 
sfConfig::get('sf_web_dir').$newpath))
             {
               continue; // If rename fails, don't update path
             }
           }
 
+          // Delete old dirs, if they are empty
+          $p = strlen($oldpath);
+          while ($p = strrpos($oldpath, '/', $p - strlen($oldpath))
+
+
           // Update path in yaml file
           $item2['path'] = str_replace('uploads', 'uploads/r/'.$repo['slug'], 
$item2['path']);
         }

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to