Index: flashvideo.module
===================================================================
--- flashvideo.module	(revision 38)
+++ flashvideo.module	(working copy)
@@ -1486,28 +1486,7 @@
         $file = (object)$file;
         // If they wanted to remove the file from the node.
         if (!empty($file->remove)) {
-          // Find the files referenced by this file being removed.
-          $files = db_query("SELECT * FROM {flashvideo} fv LEFT JOIN {files} f ON f.fid=fv.fid WHERE fv.oid = %d", $file->fid);
-          // Delete the file record from the flashvideo tables.
-          db_query("DELETE FROM {ffmpeg_data} WHERE fid = %d", $file->fid);
-          db_query("DELETE FROM {flashvideo} WHERE oid = %d", $file->fid);
-          // Iterate through all the files removed from the node.
-          while ($oldfile = db_fetch_object($files)) {
-            // Delete that file from the files and CCK content type tables as well as from the file system.
-            db_query("DELETE FROM {files} WHERE fid = %d", $oldfile->fid);
-            $cck_table = 'content_type_'. $node->type;
-            // For single-upload file fields
-            if (db_column_exists($cck_table, $cck_original_video_field .'_fid')) {
-              db_query("UPDATE {". $cck_table ."} SET ". $cck_original_video_field ."_fid = NULL, ". $cck_original_video_field ."_list = NULL, ". $cck_finished_video_field ."_fid = NULL, ". $cck_finished_video_field ."_list = NULL, ". $cck_finished_thumbnail_field ."_fid = NULL, ". $cck_finished_thumbnail_field ."_list = NULL WHERE nid = %d", $node->nid);
-            }
-            else { // For multi-upload file fields
-              db_query("DELETE FROM {content_". $cck_original_video_field ."} WHERE nid = %d", $node->nid);
-              db_query("DELETE FROM {content_". $cck_finished_video_field ."} WHERE nid = %d", $node->nid);
-              db_query("DELETE FROM {content_". $cck_finished_thumbnail_field ."} WHERE nid = %d", $node->nid);
-            }
-            file_delete($oldfile->filepath);
-            module_invoke_all('flashvideo_delete_file', $oldfile, $node->type);
-          }
+		flashvideo_file_delete($file);
         }
         else {
           // Only continue if it is a video
@@ -1602,6 +1581,27 @@
   }
 }
 
+function flashvideo_file_delete($file) {
+  // Find the files referenced by this file being removed.
+  $files = db_query("SELECT * FROM {flashvideo} fv LEFT JOIN {files} f ON f.fid=fv.fid WHERE fv.oid = %d", $file->fid);
+
+  // Delete the file record from the flashvideo tables.
+  db_query("DELETE FROM {ffmpeg_data} WHERE fid = %d", $file->fid);
+  db_query("DELETE FROM {flashvideo} WHERE oid = %d", $file->fid);
+
+  // Iterate through all the files removed from the node.
+  while ($oldfile = db_fetch_object($files)) {
+
+    // Delete that file from the files and upload tables as well as from the file system.
+    db_query("DELETE FROM {files} WHERE fid = %d", $oldfile->fid);
+    db_query("DELETE FROM {upload} WHERE fid = %d", $oldfile->fid);
+    file_delete($oldfile->filepath);
+    module_invoke_all('flashvideo_delete_file', $oldfile, $node->type);
+  }
+
+}
+
+
 /**
  *  This function will search for a filepath, trying several commons paths.
  *
