mail import assumes berkeley mailbox stores

RESOLVED FIXED in Thunderbird 15.0

Status

MailNews Core
Import
RESOLVED FIXED
6 years ago
5 years ago

People

(Reporter: Bienvenu, Assigned: Bienvenu)

Tracking

(Depends on: 1 bug, Blocks: 1 bug)

Trunk
Thunderbird 15.0
x86_64
Windows 7
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 7 obsolete attachments)

(Assignee)

Description

6 years ago
The import code needs to be adapted to use pluggable stores.
(Assignee)

Comment 1

6 years ago
Created attachment 599774 [details] [diff] [review]
wip

this does Eudora import using pluggable stores, just to give you an idea (it only compiles; haven't tried linking or running yet)
(Assignee)

Updated

6 years ago
Blocks: 561562
(Assignee)

Comment 2

6 years ago
Created attachment 599849 [details] [diff] [review]
patch that builds on windows

this patch builds on windows, but I haven't tried it on mac yet, or tried running it yet.
Attachment #599774 - Attachment is obsolete: true
(Assignee)

Comment 3

6 years ago
Created attachment 600064 [details] [diff] [review]
patch that runs on windows

this works with Eudora and Outlook on Windows - I don't have OE installed, and might need some help testing that.

I need to go fix this so it builds on the mac first, though.
Attachment #599849 - Attachment is obsolete: true
(Assignee)

Comment 4

6 years ago
Created attachment 600117 [details] [diff] [review]
get building on mac

this builds on the mac
Attachment #600064 - Attachment is obsolete: true
(Assignee)

Comment 5

6 years ago
Created attachment 600138 [details] [diff] [review]
fix tabs

Hiro, do you think you could review this? You know the import code as well as anyone, and I think you're in a position to test things like Outlook Express. I'll ask Standard8 for sr since I'm changing an interface method, and he can catch any style issues.
Attachment #600117 - Attachment is obsolete: true
Attachment #600138 - Flags: superreview?(mbanner)
Attachment #600138 - Flags: review?(hiikezoe)
Comment on attachment 600138 [details] [diff] [review]
fix tabs

Review of attachment 600138 [details] [diff] [review]:
-----------------------------------------------------------------

Basically it looks good to me and works well with the patch for Windows Live Mail importer too.

Actually there a lots of space after the open bracket but I do not care about it here. I will open a new bug for those style fixes in import codes.

I am just concerned about inconsistency of the pattern of GetNewMsgOutputStream .. FinishNewMessage .. DiscardNewMessage.
Some modules are

  GetNewMsgOutputStream();
  ..
  if (NS_SUCCEEDED(rv))
    FinishNewMessage();
  else
    DiscardNewMessage();

but some are

  if (NS_FAILED(rv)) {
    DiscardNewMessage();
    break;
  }
  FinishNewMessage();

Those should be consistent. I'd prefer the pattern in nsOutlookMail.cpp:

  GetNewMsgOutputStream();
  ..
  if (NS_SUCCEEDED(rv)) {
    FinishNewMessage();
  } else {
    output some log;
    DiscardNewMessage();
  }

It's not related to this issue, nsOE5File::ImportMailbox should be clean up. The function is too long... I will work on it later.

::: mailnews/import/applemail/src/nsAppleMailImport.cpp
@@ +565,5 @@
>      nsCOMPtr<nsIOutputStream> outStream;
> +    nsCOMPtr<nsIMsgPluggableStore> msgStore;
> +    nsCOMPtr<nsIMsgDBHdr> msgHdr;
> +
> +    bool reusable;

I'd prefer msgHdr and reusable are positioned nearby GetNewMsgOutputStream.

@@ +599,4 @@
>        if (!StringEndsWith(leafName, NS_LITERAL_STRING(".emlx")))
>          continue;
>  
> +       rv = msgStore->GetNewMsgOutputStream(aDstFolder, getter_AddRefs(msgHdr), &reusable,

Indentation is slipped here.

@@ +602,5 @@
> +       rv = msgStore->GetNewMsgOutputStream(aDstFolder, getter_AddRefs(msgHdr), &reusable,
> +                                            getter_AddRefs(outStream));
> +      if (NS_FAILED(rv))
> +        break;
> +      

Remove these spaces on this blank line.

::: mailnews/import/eudora/src/nsEudoraImport.cpp
@@ +529,3 @@
>  {
>    NS_PRECONDITION(pSource != nsnull, "null ptr");
> +  NS_PRECONDITION(pDstFolder, "null ptr");

It's better to remove all '!= nsnull'? Or use NS_ENSURE_ARG_POINTER?

::: mailnews/import/eudora/src/nsEudoraMailbox.cpp
@@ +323,2 @@
>  
> +      bool reusable;

msgHdr and reusable should move nearby GetNewMsgOutputStream.

@@ +347,5 @@
>  
>          if (!readBuffer.m_bytesInBuf && (state.offset >= state.size))
>            break;
>        }
> +      outputStream->Close();

Need if (outputStream) statement.

@@ +408,5 @@
> +  nsCOMPtr<nsIOutputStream> outputStream;
> +  nsCOMPtr<nsIMsgPluggableStore> msgStore;
> +  nsCOMPtr<nsIMsgDBHdr> msgHdr;
> +
> +  bool reusable;

These msgHdr and reusable should move too.

@@ +466,2 @@
>    }
>  

Should close outputStream after the while loop.

::: mailnews/import/oexpress/nsOE5File.cpp
@@ +282,5 @@
>  
> +  nsCOMPtr<nsIInputStream> inputStream;
> +  nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), inFile);
> +  NS_ENSURE_SUCCESS(rv, rv);
> +  nsCOMPtr<nsIOutputStream> outputStream;

This outputStream should move before 'for' loop.

@@ +348,5 @@
> +    if (NS_FAILED(rv))
> +    {
> +      IMPORT_LOG1( "Mbx getting outputstream error: 0x%lx\n", rv);
> +      return false;
> +    }

I' prefer break here instead of return for closing outputStream.

::: mailnews/import/oexpress/nsOEImport.cpp
@@ +427,5 @@
>                                                PRUnichar **pSuccessLog,
>                                                bool *fatalError)
>  {
>    NS_PRECONDITION(pSource != nsnull, "null ptr");
> +  NS_PRECONDITION(dstFolder, "null ptr");

Same as I mentioning about ImportEudoraMailImpl::ImportMailbox.

::: mailnews/import/outlook/src/nsOutlookImport.cpp
@@ +430,3 @@
>  {
>    NS_PRECONDITION(pSource != nsnull, "null ptr");
> +  NS_PRECONDITION(dstFolder, "null ptr");

Same as I mentioning about ImportEudoraMailImpl::ImportMailbox.

::: mailnews/import/outlook/src/nsOutlookMail.cpp
@@ +418,3 @@
>        return( NS_ERROR_FAILURE);
>      }
>  

I' prefer break here instead of return for closing outputStream.

And m_mapi.OpenMdbEntry failure case (the case is not in this patch) too.

@@ +462,4 @@
>      }
>    }
>  
> +  outputStream->Close();

Need if (outputStream) statement here.
Attachment #600138 - Flags: review?(hiikezoe) → review-
(In reply to Hiroyuki Ikezoe (:hiro) from comment #6)
> Comment on attachment 600138 [details] [diff] [review]
> fix tabs
> 
> Review of attachment 600138 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Basically it looks good to me and works well with the patch for Windows Live
> Mail importer too.
> 
> Actually there a lots of space after the open bracket but I do not care
> about it here. I will open a new bug for those style fixes in import codes.

Opened the bug. bug 730147
(Assignee)

Comment 8

6 years ago
Created attachment 600255 [details] [diff] [review]
fix addressing comments

thx much for the speedy review. This addresses your comments, I think. I decided to go with NS_ENSURE_ARG_POINTER, since it's really a programming error, and shouldn't be expected at runtime.
Attachment #600138 - Attachment is obsolete: true
Attachment #600255 - Flags: superreview?(mbanner)
Attachment #600255 - Flags: review?(hiikezoe)
Attachment #600138 - Flags: superreview?(mbanner)
Comment on attachment 600255 [details] [diff] [review]
fix addressing comments

Review of attachment 600255 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good to me. r=me but a nit and inconsistency fix.

There are still inconsistency about DiscardNewMessage case, those should be fixed.
I said that I'd prefer no break in the case (I mean importing continues), but I changed my mind, it is better to notice the failure to user.
Because most of failure cases are possibly I/O errors, I suppose it is disk full. So user can clean up disk, and retry importing.
What do you think about it?

::: mailnews/import/oexpress/nsOEMailbox.cpp
@@ +327,4 @@
>      IMPORT_LOG1( "Mbx seek error: 0x%lx\n", offset);
>      return( false);
>    }
> +   rv = m_mbxFileInputStream->Read( (char *) pChar, cnt, &cntRead);

nit: Indentation broken.
Attachment #600255 - Flags: review?(hiikezoe) → review+
Blocks: 700920
(Assignee)

Comment 10

6 years ago
(In reply to Hiroyuki Ikezoe (:hiro) from comment #9)
> 
> There are still inconsistency about DiscardNewMessage case, those should be
> fixed.
> I said that I'd prefer no break in the case (I mean importing continues),
> but I changed my mind, it is better to notice the failure to user.
> Because most of failure cases are possibly I/O errors, I suppose it is disk
> full. 
I've tried to keep doing what the existing code did in the face of failure. Sometimes the failure might be on the reading/converting end, in which case we should continue importing, in sometimes the failure will be in writing the imported messages, and that failure is unlikely to be recoverable. I think changing how the various importers handle failure is beyond the scope of this bug.
(In reply to David :Bienvenu from comment #10)
> (In reply to Hiroyuki Ikezoe (:hiro) from comment #9)
> > 
> > There are still inconsistency about DiscardNewMessage case, those should be
> > fixed.
> > I said that I'd prefer no break in the case (I mean importing continues),
> > but I changed my mind, it is better to notice the failure to user.
> > Because most of failure cases are possibly I/O errors, I suppose it is disk
> > full. 
> I've tried to keep doing what the existing code did in the face of failure.
> Sometimes the failure might be on the reading/converting end, in which case
> we should continue importing, in sometimes the failure will be in writing
> the imported messages, and that failure is unlikely to be recoverable. I
> think changing how the various importers handle failure is beyond the scope
> of this bug.

OK. I understand.
Comment on attachment 600255 [details] [diff] [review]
fix addressing comments

There's some significant bitrotting here (which I'm surprised about), can you take a look and I'll review right away?
(Assignee)

Comment 13

5 years ago
yeah, bug 730147 essentially bit-rotted my whole patch, so I'm going to have to do it again.
(Assignee)

Comment 14

5 years ago
Created attachment 620839 [details] [diff] [review]
de-bitrotted patch

haven't been able to build this yet, due to the vc 10 switch over. Trying now.
Attachment #600255 - Attachment is obsolete: true
Attachment #600255 - Flags: superreview?(mbanner)
(Assignee)

Comment 15

5 years ago
Created attachment 620873 [details] [diff] [review]
fix typo in de-bitrotted patch

this one should build...
Attachment #620839 - Attachment is obsolete: true
Attachment #620873 - Flags: superreview?(mbanner)
Attachment #620873 - Flags: superreview?(mbanner) → superreview+
(Assignee)

Comment 16

5 years ago
fixed on trunk -http://hg.mozilla.org/comm-central/rev/c752678985e4
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 15.0
Depends on: 786683
You need to log in before you can comment on or make changes to this bug.