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

delete files only matching regexp #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tarasglek
Copy link
Contributor

I like this script, but would like to delete video files in my securitycam archive and keep pics. This achieves that.

I can now prioritize deletion of videos over static pics by issuing command in sequence

free-disk --free-bytes 400GB -d --delete-re '.*mp4$' test_dir/
free-disk --free-bytes 400GB -d --delete-re '.*jpg$' test_dir/

@fphammerle
Copy link
Owner

Thanks! I'll merge it after I added a test case (might take a few days)

@fphammerle
Copy link
Owner

Thanks! Could you rebase?

@coveralls
Copy link

coveralls commented May 12, 2022

Pull Request Test Coverage Report for Build 2313760914

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+46.9%) to 100.0%

Totals Coverage Status
Change from base Build 2287374897: 46.9%
Covered Lines: 51
Relevant Lines: 51

💛 - Coveralls

@tarasglek
Copy link
Contributor Author

tarasglek commented May 12, 2022

Hey, rebased on dev. I realized this still wasn't working right on ZFS added, a workaround. Without workaround, i'd ask free-disk to free 1gb, and it would free 12gb. I suspect other CoW filesystems with non-trivial free-space tracking would need this too

… helps with filesystems like ZFS where free-space is a lagging indicator. Indicate success on exit.
fphammerle added a commit that referenced this pull request May 12, 2022
@fphammerle
Copy link
Owner

Thanks! I merged the regex part renaming the param to --delete-path-regex (to be more explicit) and replacing re.match with re.search cause I thought it was more intuitive not to imply matching at start of path (rather specify ^ explicitly). released as v1.0.0

Before merging the second part (disk usage bug fix), I'll need to add tests first

@tarasglek
Copy link
Contributor Author

For more features see https://github.com/tarasglek/free-disk/tree/taras/precision.

I added --dry-run and units to debug output to help me debug. Also changed exit code to make chaining more robust.

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.

None yet

3 participants