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

Retention fix #196

Merged
merged 4 commits into from
Jan 9, 2020
Merged

Retention fix #196

merged 4 commits into from
Jan 9, 2020

Conversation

gazpachoking
Copy link
Contributor

Addresses issues in #195

  • Ensures directories are never deleted when handling retention
  • Ensures log extension is included in filenames when handling retention

@gazpachoking
Copy link
Contributor Author

Oops, should have run the tests locally before submitting. Requiring the dots was the one thing I knew could be made more specific, and is what's causing the failure right now. I was trying to avoid changing too much, I think to make it better we need multiple glob patterns.

@Delgan
Copy link
Owner

Delgan commented Dec 30, 2019

Thanks for the PR!
I guess it's just a small edge case, a fix is probably possible while keeping just one glob pattern. I will take a look.

@Delgan Delgan force-pushed the retention_fix branch 3 times, most recently from e5dc06b to a6dbeb6 Compare January 5, 2020 15:44
@Delgan
Copy link
Owner

Delgan commented Jan 5, 2020

@gazpachoking Ok, you was totally right, multiple glob patterns are required.

I took the liberty of making changes to your branch as a result of this PR, I hope you don't mind.

While refactoring the code, I decided to combine the glob pattern with a regex check which I think is more permissive: we want to match "file.2020-01-01_01-01-01_0000001.log" (automatic renaming on rotation), but we want to exclude both "file.foo.log" and "foo.file.log" which is complicated without regex.

At the same time, I realized it was wrong to call os.path.splitext() after glob.escape() as it would result in something like ("file\\", ".log"), so I modified the corresponding code.

Also, I tried to fix a 100%-theoretical bug that could occur if "." was present in the {time} spec format (leading to wrong splitext()).

This results in code much more convoluted unfortunately, but this should greatly reduce false positives during retention process. Does it look good to you?

@gazpachoking
Copy link
Contributor Author

It is a bit hard to read and understand the glob and regex bit, but the expanded test suite is clear, and makes me confident it's doing what it's supposed to now. 👍

@Delgan
Copy link
Owner

Delgan commented Jan 9, 2020

Great, thanks for the review! Let's merge it then. ;)

@Delgan Delgan merged commit 3b66fb5 into Delgan:master Jan 9, 2020
@Delgan Delgan mentioned this pull request Jan 9, 2020
@Delgan Delgan mentioned this pull request Mar 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants