~rjarry/aerc#281: 
Unable to open local `mbox` files

On running aerc mbox:~/mbox we expect aerc to open the local mail box which it doesn't and gives the error:

`mbox: open : no such file or directory`

aerc -v: aerc 0.18.2 (go1.23.1 arm64 darwin 2024-09-10)

I would like to work on this issue, any guidance will be helpful, on a side note I never worked with go.

Status
RESOLVED FIXED
Submitter
Syed Fasiuddin
Assigned to
No-one
Submitted
a month ago
Updated
a month ago
Labels
No labels applied.

~rjarry a month ago

~Syed Fasiuddin, Oct 12 2024:

I would like to work on this issue, any guidance will be helpful, on a side note I never worked with go.

You could start by running strace to see which file path is causing the ENOENT error.

strace -f -e trace=file -s 65535 aerc mbox:...

~konimarti a month ago

I was just about to send a fix to the mailing list when I saw that you would want to work on this issue yourself.

Here is some guidance:

  • the url.Parse command will parse the source string into different variables depending on the scheme prefix, i.e either 'mbox:' or 'mbox://'
  • url.Parse("mbox://~/mbox") will parse the path into url.Host and url.Path (this is currently expected to work correctly); however, when using url.Parse("mbox:~/mbox", without the '//') it will parse the path into url.Opaque.
  • a robust fix would make both schemes work

Syed Fasiuddin a month ago ยท edit

On Sat Oct 12, 2024 at 8:07 PM IST, ~konimarti wrote:

  • the url.Parse command will parse the source string into different variables depending on the scheme prefix, i.e either 'mbox:' or 'mbox://'
  • url.Parse("mbox://~/mbox") will parse the path into url.Host and url.Path (this is currently expected to work correctly); however, when using url.Parse("mbox:~/mbox", without the '//') it will parse the path into url.Opaque.

Yes!! I just found out what was happening and was composing the email about it and your email arrived.

Essentially this if block here is not being executed as u.Host is not ~ but instead is just nothing. But If I do aerc mbox:/Users/user/mbox though it works fine as u.Path contains this absolute path and the else block manages to set correct value for dir.

File: worker/mbox/worker.go

var dir string
		if u.Host == "~" {
			home, err := os.UserHomeDir()
			if err != nil {
				reterr = err
				break
			}
			dir = filepath.Join(home, u.Path)
		} else {
			dir = filepath.Join(u.Host, u.Path)
		}
  • a robust fix would make both schemes work How can I solve this?

~konimarti a month ago

A possible approach could be:

  • extract the url.Parse logic into a separate function that returns the path to the file (you can add test for this function)
  • if the returned path starts with '~', expand it

The body of the extracted function could look like this:

{
       var path string

       u, err := url.Parse(s)
       if err != nil {
               return path, err
       }

       if u.Host == "" {
               path = u.Path
       } else {
               path = filepath.Join(u.Host, u.Path)
       }

       if path == "" {
               path = u.Opaque
       }

       return path, err
}

~rockorager REPORTED FIXED a month ago

Syed Fasiuddin referenced this ticket in commit d13361b.

Register here or Log in to comment, or comment via email.