gauteh / lieer

Fast email-fetching and sending and two-way tag synchronization between notmuch and GMail
http://lieer.gaute.vetsj.com
Other
497 stars 60 forks source link

Unable to limit the number of emails to pull #164

Closed Lattitude75 closed 3 years ago

Lattitude75 commented 3 years ago

I have been unable to limit emails using the --limit option. Initially, I got the following error.

File "/usr/lib/python3.8/site-packages/lieer/gmailieer.py", line 608, in full_pull
    raise argparse.ArgumentError ('--limit with "remove_local_messages" will cause lots of messages to be deleted')
TypeError: __init__() missing 1 required positional argument: 'message'

After looking at the code, I found that a dry run might help, otherwise the update does not move forward and this time I repeatedly got keyError:xxxxxx like so

  File "/usr/lib/python3.8/site-packages/lieer/local.py", line 569, in update_tags
    fname = os.path.join (self.md, self.gids[gid])
KeyError: 'xxxxxxxxxxxxx'

The only way it could move ahead was by commenting out lines 607 and 608 in gmailieer.py:

      #if self.limit and not self.dry_run:
        #raise argparse.ArgumentError ('--limit with "remove_local_messages" will cause lots of messages to be deleted')

Now, I am able to limit the mails just by using:

gmi pull --limit 500

Is this a bug, or am I missing something?

gauteh commented 3 years ago

Limit was used when developing lieer, and the option should be removed. It does not work very well.

tir. 14. jul. 2020, 15:00 skrev Lattitude75 notifications@github.com:

I have been unable to limit emails using the --limit option. Initially, I got the following error.

File "/usr/lib/python3.8/site-packages/lieer/gmailieer.py", line 608, in full_pull raise argparse.ArgumentError ('--limit with "remove_local_messages" will cause lots of messages to be deleted') TypeError: init() missing 1 required positional argument: 'message'

After looking at the code, I found that a dry run might help, otherwise the update does not move forward and this time I repeatedly got keyError:xxxxxx like so

File "/usr/lib/python3.8/site-packages/lieer/local.py", line 569, in update_tags fname = os.path.join (self.md, self.gids[gid]) KeyError: 'xxxxxxxxxxxxx'

The only way it could move ahead was by commenting out lines 607 and 608 in gmailieer.py:

  #if self.limit and not self.dry_run:
    #raise argparse.ArgumentError ('--limit with "remove_local_messages" will cause lots of messages to be deleted')

Now, I am able to limit the mails just by using:

gmi pull --limit 500

Is this a bug, or am I missing something?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gauteh/lieer/issues/164, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAN36ZF3YYXT5MJFDA2GVTR3RJHPANCNFSM4OZPY5VA .

Lattitude75 commented 3 years ago

I think that feature should be added. It is very useful when you have an old email which has tens of thousands of emails, and you only want the recent ones. It was what cut my pull time from over 3 hours to about 5 minutes. Can this be added? I do not think it requires major changes too.

Edit: Also, I have been able to sync properly without any additional tags after the first full_pull.

gauteh commented 3 years ago

There is a pull request which I eventually decided not to merge with this functionality, please check out the discussion there. The limit flag is too simple.

tir. 14. jul. 2020, 16:11 skrev Lattitude75 notifications@github.com:

I think that feature should be added. It is very useful when you have an old email which has tens of thousands of emails, and you only want the recent ones. It was what cut my pull time from over 3 hours to about 5 minutes. Can this be added? I do not think it requires major changes too.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gauteh/lieer/issues/164#issuecomment-658203184, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAN363LD52UDFBFIDEIAHDR3RRQ7ANCNFSM4OZPY5VA .

Lattitude75 commented 3 years ago

Using age as a feature would be helpful. but I do understand that it has a fair bit of complexity. But, limiting by number of messages is a feature many mail sync commands including isync use. Since, it already seems to work fine, what can be done is to only let the pull with the --limit option if it is the very first run. Else, the option can be discarded with a warning. This way this feature can be added without the fear of data loss or inconsistencies. Because, it is only the very first time that this option is needed.

Lattitude75 commented 3 years ago

I created a pull request #165, to make the change. I do not think anything else is necessary.

gauteh commented 3 years ago

You could also disable local delete, using gmi set, then it would work.

tir. 14. jul. 2020, 17:55 skrev Lattitude75 notifications@github.com:

I created a pull request #165 https://github.com/gauteh/lieer/pull/165, to make the change. I do not think anything else is necessary.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gauteh/lieer/issues/164#issuecomment-658261709, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAN366FFRST6HF2FK4ZN23R3R5Y3ANCNFSM4OZPY5VA .

Lattitude75 commented 3 years ago

Yes, that works too. You can leave it here, but please do not scrap off the option --limit. It is very useful.

I'll close the issue here.