Bug: inappropriate error ”There is not enough disk space to download new messages. Try ...” but we are not downloading, when the file system does not have enough space when message(s) deletion is invoked from context menu.
Status: NEW
Priority: --
Created: 2024-03-20 06:39:17+00:00
Resolved: 2024-06-10 14:23:42+00:00

I am testing C-C TB 's behavior under low space condition to verify my patches for bug 1242030 works correctly under such error conditions.

I have found that the error message shown when I invoke message deletion (copying to Trash folder in other words) shows
INCORRECT message when I invoke the operation from the right button context menu.
(I am not sure if this problem was there about 7 years ago when I debugged the similar patch set against then current C-C source tree.)
The message shown is as follows (I will attach a screen dump) 
```
There is not enough disk space to download new messages. Try deleting old mail, emptying the Trash folder, and compacting your mail folders, and then try again.
```
This is patently wrong since I am trying to delete  the message(s) (i.e., copying to Trash folder and then deleting the original files meta information, etc.).

I inserted enough dump statement to figure out what went wrong.
Basically,  |WarnIfLocalFileTooBig| function throws out OfDiskSpace correctly, but
the shown message needs to be differentiated according to the operation that is in operation.
```
{debug} Entering nsMsgDBView::ApplyCommandToIndices...    <--- invoking delete messages right click
{debug} Entering nsMsgDBView::DeleteMessages ...
{streamdebug} value: outputStream = 0x7f0a9400dbf8 'before close in ChangeFlags' in ChangeFlags  at line 1210 of /NEW-SSD/NREF-COMM-CENTRAL/mozilla/comm/mailnews/local/src/nsMsgBrkMBoxStore.cpp
{streamdebug} value: outputStream = 0x7f0a9400dbf8 'setting to nullptr' in ChangeFlags  at line 1213 of /NEW-SSD/NREF-COMM-CENTRAL/mozilla/comm/mailnews/local/src/nsMsgBrkMBoxStore.cpp
{debug} Entering nsMsgLocalMailFolder::DeleteMessages ...
{debug} Entering nsMsgLocalMailFolder::CheckIfSpaceForCopy...  <--- checking for enough space for copying.
{debug} Entering WarnIfLocalFileTooBig ...
{debug} Entering HasSpaceAvailable ...
GetDiskSpaceAvailable returned: 3824640 bytes
aSpaceRequested               : 1051019 bytes
 // + EXTRA_SAFETY_SPACE      : 5245323 bytes
{debug} HasSpaceAvailable returning with an error
{debug} WarnIfLocalFileTooBig throwing outOfDiskSpace...  <--- here the error is thrown.
[Parent 1267285, Main Thread] WARNING: NS_ENSURE_TRUE(uri) failed: file /NEW-SSD/NREF-COMM-CENTRAL/mozilla/caps/BasePrincipal.cpp:1494
```
https://searchfox.org/comm-central/source/mailnews/local/src/nsLocalMailFolder.cpp#3428
```
    ThrowAlertMsg("outOfDiskSpace", aWindow);
```
Well, currently |outOfDiskSpace| is defined as
outOfDiskSpace=There is not enough disk space to download new messages. Try deleting old mail, emptying the Trash folder, and compacting your mail folders, and then try again.
https://searchfox.org/comm-central/source/mail/locales/en-US/chrome/messenger/messenger.properties#87
There does not seem to be an error message for low avalable space for message copy/move operation. 

Possible Solution:
Solution 1. Pass a parameter in the calling path  to WarnIfLocalFileTooBig() to indicate which operation was attempted "download/move/copy" of messages and select the appropriate message (by throwing different error).
Solution 2. Or have the caller of WarnIfLocalFileTooBig() to report the error that matches the operation being attempted.

Both 1 and 2 requires us to define a new message for low space condition for message move/copy.

It turns out case 2 may be difficult. WarnifLocalFileTooBig() is called in a couple of C++ source codes, and  in a JS code.
https://searchfox.org/comm-central/search?q=WarnIfLocalFileTooBig&redirect=false

JS code seems to be used for downloading.
I am not sure what one of the C++ caller is doing in 
https://searchfox.org/comm-central/source/mailnews/local/src/nsParseMailbox.cpp#2247

One other possibility is to change the error message.
Solution 3: Let use a generic message  a la 
```
There is not enough disk space for message operation. Try deleting old mail, emptying the Trash folder, and compacting your mail folders, and then try again.
```
But I want an error message as specific as possible and Case 3 should be avoided.
OTOH, the error appears immediately so the user may be able to associate his/her action with the error message easily.

In any case, the current message is too confusing.
Also, as it turns out nothing works from GUI to reduce space.

Ouch, trying to delete a large folder to create free space failed with 
this message in console, but nothing appears as GUI feedback. Bad. 
Another bugzilla is needed.
```
~nsMsgDatabase(): closing database    /mnt/mount-50MB-volume/Maildir/folder-E.msf
calling RemoveFromCache(this)
[Parent 1267285, Main Thread] WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80520010 (NS_ERROR_FILE_NO_DEVICE_SPACE): file /NEW-SSD/NREF-COMM-CENTRAL/mozilla/comm/mailnews/local/src/nsMsgBrkMBoxStore.cpp:636
JavaScript error: chrome://messenger/content/about3Pane.js, line 594: NS_ERROR_FILE_NO_DEVICE_SPACE: Component returned failure code: 0x80520010 (NS_ERROR_FILE_NO_DEVICE_SPACE) [nsIMsgCopyService.copyFolder]

```