Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JakkuSakura committed Sep 26, 2024
1 parent 801be18 commit ab8537c
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions pyinfra/facts/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from __future__ import annotations

import re
import shlex
import stat
from datetime import datetime
from typing import TYPE_CHECKING, List, Optional, Tuple, Union
Expand Down Expand Up @@ -352,12 +351,14 @@ def command(
"""
if args is None:
args = []

def maybe_quote(value):
return QuoteString(value) if quote_path else value

command = [
'find',
"find",
maybe_quote(path),
'-type',
"-type",
self.type_flag,
]

Expand All @@ -368,39 +369,37 @@ def maybe_quote(value):
If we use any units other than 'c', it has a weird rounding behavior,
and is implementation-specific. So, we always use 'c'
"""
if '-size' not in args:
if "-size" not in args:
if min_size is not None:
command.append('-size')
command.append('+{0}c'.format(parse_size(min_size)))
command.append("-size")
command.append("+{0}c".format(parse_size(min_size)))

if max_size is not None:
command.append('-size')
command.append('-{0}c'.format(parse_size(max_size)))
command.append("-size")
command.append("-{0}c".format(parse_size(max_size)))

if size is not None:
command.append('-size')
command.append('{0}c'.format(size))


if maxdepth is not None and '-maxdepth' not in args:
command.append('-maxdepth')
command.append('{0}'.format(maxdepth))
command.append("-size")
command.append("{0}c".format(size))

if fname is not None and '-fname' not in args:
command.append('-name')
command.append('{0}'.format(maybe_quote(fname)))
if maxdepth is not None and "-maxdepth" not in args:
command.append("-maxdepth")
command.append("{0}".format(maxdepth))

if iname is not None and '-iname' not in args:
command.append('-iname')
command.append('{0}'.format(maybe_quote(iname)))
if fname is not None and "-fname" not in args:
command.append("-name")
command.append(maybe_quote(fname))

if regex is not None and '-regex' not in args:
command.append('-regex')
command.append('{0}'.format(maybe_quote(regex)))
if iname is not None and "-iname" not in args:
command.append("-iname")
command.append(maybe_quote(iname))

if regex is not None and "-regex" not in args:
command.append("-regex")
command.append(maybe_quote(regex))

command.append('||')
command.append('true')
command.append("||")
command.append("true")

return StringCommand(*command)

Expand Down

0 comments on commit ab8537c

Please sign in to comment.