Take the use case where you edit an audio node and then reload the edit screen. This action will delete the existing audio file. This is due to the code:

// When you enter the edit view the first time we need to clear our files in
  // session for this node. This is so if you upload a file, then decide you
  // don't want it and reload the form (without posting), the files will be
  // discarded.
  if(count($_POST) == 0) {
    if (isset($_SESSION['audio_file'][$nid])) {
      // TODO: need to be able to delete unsaved temp files. the code below
      // won't work because you can't tell the difference between an uploaded
      // file and an "good" existing file.
      #file_delete($_SESSION['audio_file'][$nid]->filepath);
    }
    unset($_SESSION['audio_file'][$nid]);
  }

The idea is that if you created a node, uploaded a file, and decided you didn't want a refresh would get rid of the file.

I don't think this is a good way to go about it due to other use cases in this situation. A better way might be to provide a check box to delete the file similar to how they do it cck image node. Check the box if you want the file deleted once it's uploaded.

I have, also, found that if you just comment out this section of code it seems to work fine. If you want to replace the old file just upload a new one. If there is no audio file it won't let the node submit.

Comments

drewish’s picture

Status: Active » Closed (won't fix)

Yeah, it's commented out in the -dev version. That release shouldn't even be out there but dww's release system won't let me delete it. I'll be branching soon. You should use 5.x-0.x-dev until then.