question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

addFlags progress

See original GitHub issue

Is there a way to get the progress of addFlags method? I tried listening on update event but it’s shows nothing.

EDIT: It also doesn’t delete all messages when dealing with large mailbox (229882 messages), is there a solutions for this?

const Imap = require('imap');

const imap = new Imap({
    user: 'xxxxxxxx@yahoo.com',
    password: 'xxxxxxxxx',
    host: 'imap.mail.yahoo.com',
    port: 993,
    tls: true
});

imap.connect();

imap.on('ready', () => {
    console.log('Client ready');
    imap.openBox('INBOX', false, (err, box) => {
        if (err) error(err);
        console.log(`INBOX open (${box.messages.total})`);
        imap.seq.addFlags('1:*', 'Deleted', err => {
            if (err) error(err);
            console.log('Flags added');
            imap.expunge('1:*', err => {
                if (err) error(err);
                console.log('Expunge done');
                imap.closeBox(false, err => {
                    if (err) error(err);
                    console.log('Box closed');
                    imap.end();
                    console.log('The end');
                });
            })
        });
    });
});

imap.on('update', (seqno, info) => {
    console.log('update ' + seqno);
})

function error(err) {
    console.log('Error: ' + err.message);
    process.exit(1);
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
mscdexcommented, Aug 14, 2017

For flag modifications, currently we enforce a silent option that prevents flag updates from the server. Initially this decision was made because of how the server sends these flag updates (it sends them as FETCH responses), which made things complicated. I’m not sure if that is the case with the codebase nowadays though.

For checking for a non-empty mailbox, there are a variety of different methods to choose from, including:

  • Check mailbox.total (mailbox being the object passed to openBox() callbacks), it should update as needed, but I’m not sure offhand about after an expunge
  • Do .status() on an unopened mailbox, the callback is given a similar mailbox object as with openBox()
  • Doing something like imap.seq.fetch('1')
  • If the server supports the ESEARCH extension, you can do imap.esearch(['ALL'], ['COUNT'], (err, info) => {})
  • If the server supports the QUOTA extension, you could use imap.getQuotaRoot() and then imap.getQuota() to get usage information for a mailbox
1reaction
mscdexcommented, Aug 14, 2017

You can just do a simple .search() for messages with the deleted flag set:

imap.search([ 'DELETED' ], (err, results) => {
  if (err) throw err;
  console.log(results.length + ' messages still marked for deletion');
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

android - How to display progress screen while restarting app?
I do app restart with the following intent: Intent restartIntent = new Intent(context, MainActivity.class); restartIntent.addFlags(Intent.
Read more >
Window | Android Developers
addContentView; addFlags; addOnFrameMetricsAvailableListener; clearFlags; closeAllPanels ... Flag for setting the progress bar's indeterminate mode off.
Read more >
BossBar (adventure-api 4.12.0 API) - Kyori
Represents an in-game bossbar which can be shown to the client. A bossbar consists of: name: the title of the bossbar; progress: a...
Read more >
BossBar (Spigot-API 1.14-R0.1-SNAPSHOT API)
Method Summary ; Returns all players viewing this boss bar · Returns the progress of the bar between 0.0 and 1.0 · Returns...
Read more >
git-add Documentation - Git
The git status command can be used to obtain a summary of which files have changes that are staged for the next commit....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found