Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leap Year Issue #107

eddy-hj-kim opened this issue Feb 29, 2020 · 2 comments · Fixed by #110

Leap Year Issue #107

eddy-hj-kim opened this issue Feb 29, 2020 · 2 comments · Fixed by #110


Copy link

@eddy-hj-kim eddy-hj-kim commented Feb 29, 2020


import asyncio
import aioftp

async def get_files_path(host, port, login, password):
    async with aioftp.ClientSession(host, port, login, password) as client:
        for path, info in (await client.list(PATH)):
            print(path), port, USERNAME, PASSWORD))

It seems that aioftp fails to list up the files created after 02/29/2020 00:00.
When I used Python ftplib, I could get the correct number of files totally the same with I was checking on FileZilla.

Can you check this issue? Thanks.

Copy link

@cpuz158 cpuz158 commented Feb 29, 2020

Hello, I found this bug was related to parse_ls_date() at
aioftp seems to be not able to get files which were made on 29th Feb.

At line 371
d = datetime.datetime.strptime(s, "%b %d %H:%M")
It does not recognize 29th Feb without specifying what year.
This year 2020 is a leap year.

Here's my workaround to this issue.
I manually patched it to fix this issue in my production environment.
d = datetime.datetime.strptime(f'{now.year} {s}', "%Y %b %d %H:%M")

Hope this helps you.

Copy link

@pohmelie pohmelie commented Mar 2, 2020

The reasons why ftplib and filezilla work fine are different but obvious:

  • ftplib do not parse LIST response and just prints it out
  • filezilla have 1k+ LOC to parse LIST and the reason for this is that LIST output have no standard format.

It is better to use MLSx family commands and aioftp tries MLSx at first, but fallbacks to LIST. Main suggestion here is to update ftp server to support MLSx commands.

Nice catch. Would you make a PR?

@pohmelie pohmelie mentioned this issue Mar 5, 2020
@helpr helpr bot added the pr-available label Mar 5, 2020
pohmelie pushed a commit that referenced this issue Mar 10, 2020
* Fix leap year bug at `parse_ls_date` method

* Make `parse_ls_date` classmethod

* Add base exception class

* Improve leap year calculation

* Add history record
@helpr helpr bot added pr-merged and removed pr-available labels Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging a pull request may close this issue.

3 participants