bneijt/autotrash

Date parse error for info files

Closed this issue · 11 comments

Verion Rehat Enterprise 7 RPM autotrash-0.1.5-2.el7
This appears to be the same as the current github version (15)

However it errors while cleaning up trash generated by a debian environment....

File "/bin/autotrash", line 317, in
sys.exit(main(sys.argv))
File "/bin/autotrash", line 251, in main
file_time = trash_info_date(file_name)
File "/bin/autotrash", line 101, in trash_info_date
return time.strptime(parser.get(section, key), '%Y-%m-%dT%H:%M:%S')
File "/usr/lib64/python2.7/_strptime.py", line 467, in _strptime_time
return _strptime(data_string, format)[0]
File "/usr/lib64/python2.7/_strptime.py", line 328, in _strptime
data_string[found.end():])
ValueError: unconverted data remains: .710Z

I have not yet seen this locally, but I guess I could add support for a time format with nanoseconds and timezone information appended 🤔 I'm opening a branch to see if I can fix this with dateutil.parser

Example trash info file that it fails to parse...
Info filename... 44f9088e-87c8-4cc3-8915-18fd675458ec.trashinfo
Contents

[Trash Info]
Path=/home/user/public_html/webAppDev/week10/.env
DeletionDate=2019-08-27T05:20:31.377Z

NOTE: There is also no final newline on that last line!
It was generated by a program called 'code-server'.

Busy times, sorry.

I refactored the code in the https://github.com/bneijt/autotrash/tree/issue-15 branch. I'll do some more testing later, but if you want you could already experiment with that branch.

You will have to contact the downstream package maintainer to see when and if that package is going to be updated.
In the meantime, validate that this fix works by using:

pip install --user autotrash
export PATH=$PATH:$HOME/.local/bin
which autotrash

The last command should output that you have autotraash installed in your users .local/bin folder.

That does not look good. What version op python are you using? python --version ?

This is because of type hints missing in python 2+.
Because python 2 is end of life, I'm setting the minimum python version for the package to 3.5

Try pip3 install --user autotrash

[1] https://pythonclock.org/

I finally got to install and test....
Yeah it is handling things fine now... lts hope it gets into the up-stream providers quickly