Repository: Mailu/Mailu

Issue:
Fetchmail: /var/lib/fetchmail needs persistence
According [fetchmail documentation](https://www.fetchmail.info/fetchmail-man.html#12), an `.idfile` is used to keep track of previously downloaded messages. Shouldn't that file persistent over container restarts?

I'm not a Fetchmail user, perhaps somebody can shine a light on how this currently works?

cc: @Nebukadneza, @hoellen, @kaiyou 


Discussion:
Yes, same here. I just updated mailu using

    docker-compose pull && docker-compose up -d --build

and now I received hundreds of duplicate mails.

image is: mailu/fetchmail:1.6

Which file we need is clear:

```
# docker container diff mailu_fetchmail_1
C /var
C /var/lib
C /var/lib/fetchmail
A /var/lib/fetchmail/.ash_history
A /var/lib/fetchmail/.fetchids
```

so I modified my docker-compose.yml like this:

```
  fetchmail:
    volumes:
      - "/mnt/data-containerdata/mailu/fetchmail:/var/lib/fetchmail"
```
and pre-filled it using:

```
# docker cp mailu_fetchmail_1:/var/lib/fetchmail .
# docker exec -ti mailu_fetchmail_1 ls -lan /var/lib/fetchmail
total 20
drwxr-xr-x    1 100      101           4096 Oct 23 20:12 .
drwxr-xr-x    1 0        0             4096 Oct 20 21:15 ..
-rw-------    1 100      101              0 Oct 23 20:12 .ash_history
-rw-------    1 100      101           4930 Oct 23 19:54 .fetchids
# rm fetchmail/.ash_history 
# chown -R 100.101 fetchmail/
# ls -lan fetchmail/
total 16
drwxr-xr-x  2 100 101 4096 Oct 23 22:21 .
drwxr-xr-x 13   0   0 4096 Oct 23 22:20 ..
-rw-------  1 100 101 4930 Oct 23 21:54 .fetchids
# docker-compose up -d fetchmail
Recreating mailu_fetchmail_1 ... done
```
Is this a new requirement? I remember using fetchmail intensively at first and not bumping into this.
it only happens if the "Keep emails" option is set in "Fetched accounts".

It's about the file which keeps track which mails were already downloaded. Without this file, all mails on the server are considered "new"
@kaiyou @hoellen @muhlemmer , I see that flavors/stack/docker-compose.yml already proposes a volume : 
   - "{{ root }}/data:/data"
I propose it should rather be  - "{{ root }}/fetchmail:/var/lib/fetchmail" and that we push the same change on setup/flavors/compose/docker-compose.yml and docs/compose/docker-compose.yml ?
I can push a PR for this if needed
With version 1.7, the file is now in /home/fetchmail/, see

```
# docker diff mailu_fetchmail_1
C /home
C /home/fetchmail
A /home/fetchmail/.fetchids
```

This led again to a lot of duplicates in my mailbox.

@ofthesun9: I also vote for a path like fetchmail on host side. but it must also match with the container inside
Hi There,

The `Mailu`-Project is currently in a bit of a bind! We are short on man-power, and we need to judge if it is possible for us to put in some work on this issue.

To help with that, we are currently trying to find out which issues are actively keeping users from using `Mailu`, which issues have someone who want to work on them — and which issues may be less important. These a less important ones could be discarded for the time being, until the project is in a more stable and regular state once again.

In order for us to better assess this, it would be helpful if you could put a **reaction on this post** (use the :smiley: icon to the top-right).
- 👍️ if you **need this** to be able to use Mailu. Ideally, you’d also be able to test this on your installation, and provide feedback …
- 🎉 if you find it a **nice bonus**, but no deal-breaker
- 🚀 if you want to **work on it yourself**!
We want to keep this **voting open for 2 weeks** from now, so please help out!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.


Resolving patch:
diff --git a/optional/fetchmail/fetchmail.py b/optional/fetchmail/fetchmail.py
--- a/optional/fetchmail/fetchmail.py
+++ b/optional/fetchmail/fetchmail.py
@@ -13,6 +13,7 @@
 
 FETCHMAIL = """
 fetchmail -N \
+    --idfile /data/fetchids --uidl \
     --sslcertck --sslcertpath /etc/ssl/certs \
     -f {}
 """


Test patch: