Index: demo.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/demo/demo.admin.inc,v
retrieving revision 1.1.2.8
diff -u -p -r1.1.2.8 demo.admin.inc
--- demo.admin.inc	13 Feb 2009 03:37:32 -0000	1.1.2.8
+++ demo.admin.inc	14 May 2009 15:48:45 -0000
@@ -55,7 +55,7 @@ function demo_admin_settings() {
     '#title' => t('Dump path'),
     '#default_value' => $fileconfig['path'],
     '#size' => 30,
-    '#description' => t('Enter a writable directory where dump files of this demonstration site are stored, f.e. %files. The name of this site (e.g. %confpath) is automatically appended to this directory.<br /><br /><strong>Note: For security reasons you should store site dumps outside of the document root of your webspace!</strong>', array('%files' => file_directory_path() .'/demo', '%confpath' => $fileconfig['site'])),
+    '#description' => t('Enter a writable directory where dump files of this demonstration site are stored, f.e. %files. The name of this site (e.g. %confpath) is automatically appended to this directory, if required.<br /><br /><strong>Note: For security reasons you should store site dumps outside of the document root of your webspace!</strong>', array('%files' => file_directory_path() .'/demo', '%confpath' => $fileconfig['site'])),
   );
   $form[] = array(
     '#type' => 'submit',
@@ -303,8 +303,12 @@ function demo_get_fileconfig($filename =
   
   // Build dump path.
   $fileconfig['path'] = variable_get('demo_dump_path', file_directory_path() .'/demo');
+  $fileconfig['dumppath'] = $fileconfig['path'];
+  // Append site name if it is not included in file_directory_path().
   $fileconfig['site'] = str_replace('sites', '', conf_path());
-  $fileconfig['dumppath'] = $fileconfig['path'] . $fileconfig['site'];
+  if (strpos(file_directory_path(), conf_path()) === FALSE) {
+    $fileconfig['dumppath'] .= $fileconfig['site'];
+  }
   
   // Check if directory exists.
   file_check_directory($fileconfig['path'], FILE_CREATE_DIRECTORY, 'path');
@@ -324,11 +328,11 @@ function demo_get_fileconfig($filename =
     
   // Build SQL filename.
   $fileconfig['sql'] = $filename .'.sql';
-  $fileconfig['sqlfile'] = $fileconfig['path'] . $fileconfig['site'] .'/'. $filename .'.sql';
+  $fileconfig['sqlfile'] = $fileconfig['dumppath'] .'/'. $fileconfig['sql'];
   
   // Build info filename.
   $fileconfig['info'] = $filename .'.info';
-  $fileconfig['infofile'] = $fileconfig['path'] . $fileconfig['site'] .'/'. $filename .'.info';
+  $fileconfig['infofile'] = $fileconfig['dumppath'] .'/'. $fileconfig['info'];
   
   return $fileconfig;
 }
Index: demo.install
===================================================================
RCS file: demo.install
diff -N demo.install
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ demo.install	14 May 2009 15:47:54 -0000
@@ -0,0 +1,35 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Demonstration site module installation.
+ */
+
+/**
+ * Move existing demo dumps to new location.
+ */
+function demo_update_6100() {
+  $ret = array();
+
+  if (strpos(file_directory_path(), conf_path()) !== FALSE) {
+    // file_directory_path() already contains the site name, move existing
+    // files to the new location.
+    $new_path = file_directory_path() .'/demo';
+    $old_path = $new_path . str_replace('sites', '', conf_path());
+    if ($new_path != $old_path && file_check_directory($old_path)) {
+      // Fetch list of available files.
+      $files = file_scan_directory($old_path, '\.(info|sql)$');
+      foreach ($files as $file) {
+        rename($file->filename, $new_path .'/'. $file->basename);
+      }
+      // Ignore any warnings from rmdir() about unrelated files in the old
+      // directory (they will NOT be deleted).
+      @rmdir($old_path);
+      $ret[] = array('success' => TRUE, 'query' => t('The demo snapshot files have been successfully moved to %path.', array('%path' => $new_path)));
+    }
+  }
+
+  return $ret;
+}
+
