<<< Date Index >>>     <<< Thread Index >>>

"save attachment" message stays there, if permission denied - no error immediately reported



Hi,

Compiled from latest CVS.
I'm logged as bare user. I read a message, "v", "s" (to save an
attachment), type a name of an already existing file, "o" to
overwrite, and the file belonged to "root", so cannot be overwritten,
Mutt stays there: 

-- Mutt: Attachments
Save to file: /tmp/toto

(it's fact it's reprompting me for the filename).
Visually, nothing happens: I press "Enter" to send Mutt the filename,
then "o", and it goes back to prompt, showing me the filename I
entered, and if I press Enter again, then it does not ask for
overwrite, just stays there, saying:
Save to file: /tmp/toto
Enter and Enter again just leaves this line without anything else (at
least anything which I could notice on the screen).

It's slightly confusing though I understand this is no big deal.

If I then erase the filename (backspace etc) and press Enter (an
awkward idea), I see
fopen: Permission denied (errno = 13)
which is what I expected. But it's surprising that I can only get it
after erasing the filename.

This part of recvattach.c could be the place to look at:

static int mutt_query_save_attachment (FILE *fp, BODY *body, HEADER *hdr, char 
**directory)
<cut>
    else
    {
      if ((rc = mutt_check_overwrite (body->filename, buf, tfile, sizeof 
(tfile), &append, directory)) == -1)
        return -1;
      else if (rc == 1)
      {
        prompt = _("Save to file: ");
        continue;
      }
    }
    
    mutt_message _("Saving...");
    if (mutt_save_attachment (fp, body, tfile, append, (hdr || !is_message) ? 
hdr : body->hdr) == 0)
    {
      mutt_message _("Attachment saved.");
      return 0;
    }
    else
    {
      prompt = _("Save to file: ");
      continue;
    }
  }


Ideally I would have expected, when pressing "o", to be informed of
the error.
Suggestions:

in the function above, replace most of

        prompt = _("Save to file: ");
        continue;

by

        prompt = _("Error writing to file - Please choose another file - Save 
to file: ");
        continue;

If we want the Deluxe version, make prompt char[100] and:

        sprintf(prompt, _("Error writing to file (errno: %d") - Please choose 
another file - Save to file: ",errno);
        continue;

Or, keep the prompt variable as it is, print the fopen() error and
don't re-prompt, or print the fopen() error, sleep one second and
re-prompt...

Just raw ideas.

Guilhem

-- 
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Mr. Guilhem Bichot <guilhem@xxxxxxxxx>
 / /|_/ / // /\ \/ /_/ / /__   MySQL AB, Full-Time Software Developer
/_/  /_/\_, /___/\___\_\___/   Bordeaux, France
       <___/   www.mysql.com