Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 18324)
+++ wp-includes/post.php	(working copy)
@@ -3735,7 +3735,7 @@
 
 	$meta = wp_get_attachment_metadata( $post_id );
 	$backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true );
-	$file = get_attached_file( $post_id );
+	$file = $meta['file'];
 
 	if ( is_multisite() )
 		delete_transient( 'dirsize_cache' );
@@ -3767,38 +3767,30 @@
 	$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $post_id ));
 	do_action( 'deleted_post', $post_id );
 
-	$uploadpath = wp_upload_dir();
-
 	if ( ! empty($meta['thumb']) ) {
 		// Don't delete the thumb if another attachment uses it
 		if (! $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE %s AND post_id <> %d", '%' . $meta['thumb'] . '%', $post_id)) ) {
 			$thumbfile = str_replace(basename($file), $meta['thumb'], $file);
-			$thumbfile = apply_filters('wp_delete_file', $thumbfile);
-			@ unlink( path_join($uploadpath['basedir'], $thumbfile) );
+			wp_delete_file( $thumbfile );
 		}
 	}
 
 	// remove intermediate and backup images if there are any
 	foreach ( get_intermediate_image_sizes() as $size ) {
 		if ( $intermediate = image_get_intermediate_size($post_id, $size) ) {
-			$intermediate_file = apply_filters('wp_delete_file', $intermediate['path']);
-			@ unlink( path_join($uploadpath['basedir'], $intermediate_file) );
+			wp_delete_file( $intermediate['path'] );
 		}
 	}
 
-	if ( is_array($backup_sizes) ) {
+	if ( is_array( $backup_sizes ) ) {
 		foreach ( $backup_sizes as $size ) {
 			$del_file = path_join( dirname($meta['file']), $size['file'] );
-			$del_file = apply_filters('wp_delete_file', $del_file);
-			@ unlink( path_join($uploadpath['basedir'], $del_file) );
+			wp_delete_file( $del_file );
 		}
 	}
 
-	$file = apply_filters('wp_delete_file', $file);
+	wp_delete_file( $file );
 
-	if ( ! empty($file) )
-		@ unlink($file);
-
 	clean_post_cache($post_id);
 
 	return $post;
Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php	(revision 18324)
+++ wp-includes/media.php	(working copy)
@@ -669,6 +669,22 @@
 }
 
 /**
+ * Applies the 'wp_delete_file' filter before deleting the file
+ *
+ * @since 3.3
+ *
+ * @param string $file A file path, absolute or relative to the wp-uploads directory
+ */
+function wp_delete_file( $file ) {
+	$file = apply_filters( 'wp_delete_file', $file );
+
+	if ( !empty( $file ) ) {
+		$wud = wp_upload_dir();
+		@unlink( path_join( $wud['basedir'], $file ) );
+	}
+}
+
+/**
  * Adds a 'wp-post-image' class to post thumbnail thumbnails
  * Uses the begin_fetch_post_thumbnail_html and end_fetch_post_thumbnail_html action hooks to
  * dynamically add/remove itself so as to only filter post thumbnail thumbnails
@@ -1438,4 +1454,4 @@
 	return apply_filters( 'embed_googlevideo', '<embed type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docid=' . esc_attr($matches[2]) . '&amp;hl=en&amp;fs=true" style="width:' . esc_attr($width) . 'px;height:' . esc_attr($height) . 'px" allowFullScreen="true" allowScriptAccess="always" />', $matches, $attr, $url, $rawattr );
 }
 
-?>
\ No newline at end of file
+?>
