win_find fix up age parameter (#23195)

This commit is contained in:
Jordan Borean 2017-04-04 04:43:07 +10:00 committed by Matt Davis
commit 3e1a16c574
3 changed files with 72 additions and 112 deletions

View file

@ -111,12 +111,12 @@ Function Assert-Age($info) {
if ($specified_seconds -ge 0) {
$start_date = (Get-Date).AddSeconds($abs_seconds * -1)
if ($age_comparison -lt $start_date) {
if ($age_comparison -gt $start_date) {
$valid_match = $false
}
} else {
$start_date = (Get-Date).AddSeconds($abs_seconds)
if ($age_comparison -gt $start_date) {
if ($age_comparison -lt $start_date) {
$valid_match = $false
}
}
@ -246,13 +246,13 @@ Function Get-FileStat($file) {
filename = $file.Name
}
$islink = $false
$islnk = $false
$isdir = $false
$isshared = $false
if ($attributes -contains 'ReparsePoint') {
# TODO: Find a way to differenciate between soft and junction links
$islink = $true
$islnk = $true
$isdir = $true
# Try and get the symlink source, can result in failure if link is broken
@ -287,7 +287,7 @@ Function Get-FileStat($file) {
}
}
$file_stat.islink = $islink
$file_stat.islnk = $islnk
$file_stat.isdir = $isdir
$file_stat.isshared = $isshared
@ -326,7 +326,7 @@ foreach ($path in $paths) {
Fail-Json $result "Argument path $path does not exist cannot get information on"
}
}
$paths_to_check = $paths_to_check | Select -Unique
$paths_to_check = $paths_to_check | Select-Object -Unique
foreach ($path in $paths_to_check) {
$file = Get-Item -Force -Path $path

View file

@ -23,7 +23,6 @@ ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = r'''
---
module: win_find
@ -36,15 +35,15 @@ options:
age:
description:
- Select files or folders whose age is equal to or greater than
the specified tim. Use a negative age to find files equal to or
less than the specified time. You can choose seconds, minues,
the specified time. Use a negative age to find files equal to or
less than the specified time. You can choose seconds, minutes,
hours, days or weeks by specifying the first letter of an of
those words (e.g., "1w").
those words (e.g., "2s", "10d", 1w").
required: false
age_stamp:
description:
- Choose the file property against which we compare C(age). The
default attribute we compare with is last modification time.
default attribute we compare with is the last modification time.
required: false
default: mtime
choices: ['atime', 'mtime', 'ctime']
@ -271,7 +270,7 @@ files:
returned: success, path exists
type: boolean
sample: True
islink:
islnk:
description: if the path is a symbolic link or junction or not
returned: success, path exists
type: boolean