Index: commands/sql/sync.sql.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/commands/sql/sync.sql.inc,v
retrieving revision 1.7
diff -u -p -r1.7 sync.sql.inc
--- commands/sql/sync.sql.inc	27 Dec 2009 01:45:51 -0000	1.7
+++ commands/sql/sync.sql.inc	28 Dec 2009 23:14:33 -0000
@@ -58,19 +58,6 @@ function _drush_sql_sync($source, $desti
   $target_remote_port = drush_get_option('target-remote-port');
   $target_rsync_options = array();
 
-  // Prompt for confirmation. This is destructive.
-  if (!drush_get_context('DRUSH_SIMULATE') && $show_warning) {
-    $txt_source = (isset($source_remote_host) ? $source_remote_host . '/' : '') . $source_db_url['database'];
-    $txt_destination = (isset($target_remote_host) ? $target_remote_host . '/' : '') . $target_db_url['database'];
-    drush_print(dt("You will destroy data from !target and replace with data from !source.", array('!source' => $txt_source, '!target' => $txt_destination)));
-    drush_print();
-    // TODO: actually make the backup if desired.
-    drush_print(dt("You might want to make a backup first, using sql_dump command.\n"));
-    if (!drush_confirm(dt('Do you really want to continue?'))) {
-      drush_die('Aborting.');
-    }
-  }
-
   // Set up the result file and the remote file.
   // If the result file is not set, then create a temporary file.
   // If the remote file is not set, use the same name for the remote
@@ -120,6 +107,28 @@ function _drush_sql_sync($source, $desti
     drush_print(dt('WARNING:  Using temporary files to store and transfer sql dump.  It is recommended that you specify --source-dump and --target-dump options on the command line, or set \'!dump\' in the path-aliases section of your site alias records. This facilitates fast file transfer via rsync.'));
   }
 
+  // Prompt for confirmation. This is destructive.
+  if (!drush_get_context('DRUSH_SIMULATE') && $show_warning) {
+    $txt_source = (isset($source_remote_host) ? $source_remote_host . '/' : '') . $source_db_url['database'];
+    $txt_destination = (isset($target_remote_host) ? $target_remote_host . '/' : '') . $target_db_url['database'];
+    drush_print(dt("You will destroy data from !target and replace with data from !source.", array('!source' => $txt_source, '!target' => $txt_destination)));
+    drush_print();
+    // TODO: actually make the backup if desired.
+    drush_print(dt("You might want to make a backup first, using sql_dump command.\n"));
+    if (!drush_confirm(dt('Do you really want to continue?'))) {
+      if ($source_is_tmp) {
+	unlink($source_dump);
+      }
+      if ($target_is_tmp) {
+	unlink($target_dump);
+      }
+      if ($local_is_tmp) {
+	unlink($local_file);
+      }
+      drush_die('Aborting.');
+    }
+  }
+
   // If source is remote, then use ssh to dump the database and then rsync to local machine
   // If source is local, call drush_sql_dump to dump the database to local machine
   // In either case, the '--no-dump' option will cause the sql dump step to be skipped, and
@@ -272,13 +281,13 @@ function _drush_sql_sync($source, $desti
 
   drush_op('system', $import_exec);
   // delete local temporary files
-  if (($source_is_tmp) && (!isset($source_remote_host))) {
-    drush_op('unlink', $source_dump);
+  if ($source_is_tmp) {
+    unlink($source_dump);
   }
-  if (($target_is_tmp) && (!isset($target_remote_host))) {
-    drush_op('unlink', $target_dump);
+  if ($target_is_tmp) {
+    unlink($target_dump);
   }
   if ($local_is_tmp) {
-    drush_op('unlink', $local_file);
+    unlink($local_file);
   }
 }
