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 21:31:06 -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,8 @@ '{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']))); + demo_dump_db($fileconfig['sqlgzfile'], $exclude); + drupal_set_message(t('Successfully created snapshot %filename.', array('%filename' => $fileconfig['sqlgzfile']))); } else { drupal_set_message(t('@engine support not implemented yet.', array('@engine' => ucfirst($engine))), 'error'); @@ -221,12 +222,15 @@ function demo_reset($filename = 'demo_site', $verbose = TRUE) { $fileconfig = demo_get_fileconfig($filename); + // Attempt to open the file from the .sql file first, then attempt the .sql.gz file. 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'); + if (!file_exists($fileconfig['sqlgzfile']) || !($fp = fopen('compress.zlib://'. $fileconfig['sqlgzfile'], '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 +285,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 +333,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 +352,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 21:31:06 -0000 @@ -16,7 +16,7 @@ return FALSE; } - if ($fp = fopen($filename, 'wb')) { + if ($fp = gzopen($filename, 'w9')) { $header = "-- Demo.module database dump (version " . DEMO_DUMP_VERSION . ")\n"; $header .= "-- http://drupal.org/project/demo\n"; $header .= "--\n"; @@ -31,17 +31,17 @@ foreach (demo_enum_tables() as $table) { // Always export structure to allow creating a new site // from a database dump - fwrite($fp, _demo_dump_table_structure($table)); + gzwrite($fp, _demo_dump_table_structure($table)); if (!in_array($table, $exclude)) { - fwrite($fp, _demo_dump_table_data($table)); + gzwrite($fp, _demo_dump_table_data($table)); } } // Re-enable foreign key checks. - fwrite($fp, "\nSET FOREIGN_KEY_CHECKS = 1;\n"); + gzwrite($fp, "\nSET FOREIGN_KEY_CHECKS = 1;\n"); - fclose($fp); + gzclose($fp); return TRUE; }