Index: demo.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/demo/demo.admin.inc,v
retrieving revision 1.1.2.11
diff -u -r1.1.2.11 demo.admin.inc
--- demo.admin.inc	17 May 2009 13:25:01 -0000	1.1.2.11
+++ demo.admin.inc	8 Jun 2009 22:14:11 -0000
@@ -119,6 +119,7 @@
 function demo_delete_confirm_submit($form, &$form_state) {
   $files = demo_get_fileconfig($form_state['values']['filename']);
   unlink($files['sqlfile']);
+  unlink($files['sqlgzfile']);
   unlink($files['infofile']);
   drupal_set_message(t('Snapshot %title has been deleted.', array('%title' => $form_state['values']['filename'])));
   $form_state['redirect'] = 'admin/build/demo/manage';
@@ -187,8 +188,13 @@
       '{watchdog}',
     );
     $exclude = array_map('db_prefix_tables', $exclude);
-    demo_dump_db($fileconfig['sqlfile'], $exclude);
-    drupal_set_message(t('Successfully created snapshot %filename.', array('%filename' => $fileconfig['sqlfile'])));
+    // Create the database dump and report on success or failure.
+    if (demo_dump_db($fileconfig['sqlfile'], $exclude)) {;
+      drupal_set_message(t('Successfully created snapshot %filename.', array('%filename' => $fileconfig['sqlgzfile'])));
+    }
+    else {
+      drupal_set_message(t('Failed to create snapshot %filename.', array('%filename' => $fileconfig['sqlgzfile'])), 'error');
+    }
   }
   else {
     drupal_set_message(t('@engine support not implemented yet.', array('@engine' => ucfirst($engine))), 'error');
@@ -221,12 +227,16 @@
 
 function demo_reset($filename = 'demo_site', $verbose = TRUE) {
   $fileconfig = demo_get_fileconfig($filename);
-  if (!file_exists($fileconfig['sqlfile']) || !($fp = fopen($fileconfig['sqlfile'], 'r'))) {
-    if ($verbose) {
-      drupal_set_message(t('Unable to open dump file %filename.', array('%filename' => $fileconfig['sqlfile'])), 'error');
+  // Attempt to open the file from the .sql.gz file first, then if that fails,
+  // attempt the .sql file.
+  if (!file_exists($fileconfig['sqlgzfile']) || !($fp = @fopen('compress.zlib://'. $fileconfig['sqlgzfile'], 'r'))) {
+    if (!file_exists($fileconfig['sqlfile']) || !($fp = fopen($fileconfig['sqlfile'], 'r'))) {
+      if ($verbose) {
+        drupal_set_message(t('Unable to open dump file %filename.', array('%filename' => $fileconfig['sqlfile'])), 'error');
+      }
+      watchdog('demo', 'Unable to open dump file %filename.', array('%filename' => $fileconfig['sqlfile']), WATCHDOG_ERROR);
+      return FALSE;
     }
-    watchdog('demo', 'Unable to open dump file %filename.', array('%filename' => $fileconfig['sqlfile']), WATCHDOG_ERROR);
-    return FALSE;
   }
 
   // Load any database information in front of reset.
@@ -281,15 +291,15 @@
 
   if ($success) {
     if ($verbose) {
-      drupal_set_message(t('Successfully restored database from %filename.', array('%filename' => $fileconfig['sqlfile'])));
+      drupal_set_message(t('Successfully restored database from %filename.', array('%filename' => $fileconfig['sqlgzfile'])));
     }
-    watchdog('demo', 'Successfully restored database from %filename.', array('%filename' => $fileconfig['sqlfile']), WATCHDOG_NOTICE);
+    watchdog('demo', 'Successfully restored database from %filename.', array('%filename' => $fileconfig['sqlgzfile']), WATCHDOG_NOTICE);
   }
   else {
     if ($verbose) {
-      drupal_set_message(t('Failed restoring database from %filename.', array('%filename' => $fileconfig['sqlfile'])), 'error');
+      drupal_set_message(t('Failed restoring database from %filename.', array('%filename' => $fileconfig['sqlgzfile'])), 'error');
     }
-    watchdog('demo', 'Failed restoring database from %filename.', array('%filename' => $fileconfig['sqlfile']), WATCHDOG_ERROR);
+    watchdog('demo', 'Failed restoring database from %filename.', array('%filename' => $fileconfig['sqlgzfile']), WATCHDOG_ERROR);
   }
 
   // Reset default dump to load on cron.
@@ -329,7 +339,9 @@
 
   // Build SQL filename.
   $fileconfig['sql'] = $filename . '.sql';
+  $fileconfig['sqlgz'] = $fileconfig['sql'] .'.gz';
   $fileconfig['sqlfile'] = $fileconfig['dumppath'] . '/' . $fileconfig['sql'];
+  $fileconfig['sqlgzfile'] = $fileconfig['dumppath'] . '/' . $fileconfig['sqlgz'];
 
   // Build info filename.
   $fileconfig['info'] = $filename . '.info';
@@ -346,7 +358,8 @@
 
   foreach ($files as $file => $object) {
     $files[$file]->filemtime = filemtime($file);
-    $files[$file]->filesize = filesize(substr($file, 0, -4) . 'sql');
+    $sql = substr($file, 0, -4) . 'sql';
+    $files[$file]->filesize = file_exists($sql) ? filesize($sql) : filesize($sql .'.gz');
   }
 
   // Sort snapshots by date (ascending file modification time)
Index: database_mysql_dump.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/demo/database_mysql_dump.inc,v
retrieving revision 1.5.2.6
diff -u -r1.5.2.6 database_mysql_dump.inc
--- database_mysql_dump.inc	17 May 2009 13:25:01 -0000	1.5.2.6
+++ database_mysql_dump.inc	8 Jun 2009 22:14:11 -0000
@@ -16,7 +16,9 @@
     return FALSE;
   }
 
-  if ($fp = fopen($filename, 'wb')) {
+  // Use file compression if it's available.
+  $fp = function_exists('gzopen') ? gzopen($filename .'.gz', 'wb9') : fopen($filename, 'wb');
+  if ($fp !== FALSE) {
     $header = "-- Demo.module database dump (version " . DEMO_DUMP_VERSION . ")\n";
     $header .= "-- http://drupal.org/project/demo\n";
     $header .= "--\n";
