diff --git a/PkgStore.Vault.psm1 b/PkgStore.Vault.psm1 index 4138d41..6c19ec9 100644 --- a/PkgStore.Vault.psm1 +++ b/PkgStore.Vault.psm1 @@ -1,9 +1,9 @@ -$ModuleManifest = (Get-ChildItem -Path $PSScriptRoot | Where-Object {$_.Extension -eq '.psd1'}) +$ModuleManifest = (Get-ChildItem -Path $PSScriptRoot | Where-Object { $_.Extension -eq '.psd1' }) $CurrentManifest = (Test-ModuleManifest $ModuleManifest) $Aliases = @() -$PrivateFunctions = (Get-ChildItem -Path (Join-Path $PSScriptRoot 'Private') | Where-Object {$_.Extension -eq '.ps1'}) -$PublicFunctions = (Get-ChildItem -Path (Join-Path $PSScriptRoot 'Public') | Where-Object {$_.Extension -eq '.ps1'}) +$PrivateFunctions = (Get-ChildItem -Path (Join-Path $PSScriptRoot 'Private') | Where-Object { $_.Extension -eq '.ps1' }) +$PublicFunctions = (Get-ChildItem -Path (Join-Path $PSScriptRoot 'Public') | Where-Object { $_.Extension -eq '.ps1' }) (@($PrivateFunctions) + @($PublicFunctions)) | ForEach-Object { try { @@ -25,10 +25,10 @@ $PublicFunctions = (Get-ChildItem -Path (Join-Path $PSScriptRoot 'Public') | Whe } } -$FunctionsAdded = ($PublicFunctions | Where-Object {$_.BaseName -notin $CurrentManifest.ExportedFunctions.Keys}) -$FunctionsRemoved = ($CurrentManifest.ExportedFunctions.Keys | Where-Object {$_ -notin $PublicFunctions.BaseName}) -$AliasesAdded = ($Aliases | Where-Object {$_ -notin $CurrentManifest.ExportedAliases.Keys}) -$AliasesRemoved = ($CurrentManifest.ExportedAliases.Keys | Where-Object {$_ -notin $Aliases}) +$FunctionsAdded = ($PublicFunctions | Where-Object { $_.BaseName -notin $CurrentManifest.ExportedFunctions.Keys }) +$FunctionsRemoved = ($CurrentManifest.ExportedFunctions.Keys | Where-Object { $_ -notin $PublicFunctions.BaseName }) +$AliasesAdded = ($Aliases | Where-Object { $_ -notin $CurrentManifest.ExportedAliases.Keys }) +$AliasesRemoved = ($CurrentManifest.ExportedAliases.Keys | Where-Object { $_ -notin $Aliases }) if ($FunctionsAdded -or $FunctionsRemoved -or $AliasesAdded -or $AliasesRemoved) { try { diff --git a/Private/Compress-VaultData.ps1 b/Private/Compress-VaultData.ps1 index 79f4426..8d4cd02 100644 --- a/Private/Compress-VaultData.ps1 +++ b/Private/Compress-VaultData.ps1 @@ -1,4 +1,12 @@ function Compress-VaultData() { + <# + .SYNOPSIS + Compressing data. + + .DESCRIPTION + Compressing the Vault data with compression level 9. + #> + param( [Alias('P')][string]$Path, [Alias('N')][string]$Name, diff --git a/Private/Start-VaultMoveFiles.ps1 b/Private/Start-VaultMoveFiles.ps1 index 3e5ec35..f9e9365 100644 --- a/Private/Start-VaultMoveFiles.ps1 +++ b/Private/Start-VaultMoveFiles.ps1 @@ -1,4 +1,12 @@ function Start-VaultMoveFiles() { + <# + .SYNOPSIS + Moving files. + + .DESCRIPTION + Moving files from the Source to the Vault. + #> + param( [string]$Mode, [string]$Source, diff --git a/Private/Start-VaultRemoveDirs.ps1 b/Private/Start-VaultRemoveDirs.ps1 index d7affa1..24d81f8 100644 --- a/Private/Start-VaultRemoveDirs.ps1 +++ b/Private/Start-VaultRemoveDirs.ps1 @@ -1,4 +1,12 @@ function Start-VaultRemoveDirs() { + <# + .SYNOPSIS + Removing directories. + + .DESCRIPTION + Removing empty directories in the Source. + #> + param( [string]$Source, [long]$CreationTime, diff --git a/Public/Start-Vault.ps1 b/Public/Start-Vault.ps1 index 0758314..dd2265d 100644 --- a/Public/Start-Vault.ps1 +++ b/Public/Start-Vault.ps1 @@ -1,34 +1,74 @@ function Start-Vault { - param( - [Parameter(HelpMessage="Script operation mode. Default: 'MV'.")] - [ValidateSet('CP', 'MV', 'RM')] - [Alias('M')][string]$Mode = 'MV', + <# + .SYNOPSIS + PowerShell Vault. - [Parameter(Mandatory, HelpMessage="Path to the source. E.g.: 'C:\Data\Source'.")] - [Alias('SRC')][string]$Source, + .DESCRIPTION + The module moves files to Vault based on various criteria. - [Parameter(Mandatory, HelpMessage="Path to the Vault. E.g.: 'C:\Data\Vault'.")] - [Alias('DST')][string]$Vault, + .PARAMETER Mode + Script operation mode: + 'CP' | Coping data from the Source. + 'MV' | Moving data from the Source. + 'RM' | Only removing data from the Source. + Default: 'MV'. - [Parameter(HelpMessage="Time since file creation (in seconds). E.g.: '5270400'. Default: 61 day (5270400 sec.).")] - [Alias('CT')][long]$CreationTime = 5270400, + .PARAMETER Source + Path to the source. E.g.: 'C:\Source'. - [Parameter(HelpMessage="Time since file modification (in seconds). E.g.: '5270400'. Default: 61 day ('5270400' sec.).")] - [Alias('WT')][long]$LastWriteTime = $CreationTime, + .PARAMETER Vault + Path to the Vault. E.g.: 'D:\Vault'. - [Parameter(HelpMessage="File size check. E.g.: '5kb' / '12mb'. Default: '0kb'.")] - [Alias('FS')][string]$FileSize = '0kb', + .PARAMETER CreationTime + Time since file creation (in seconds). E.g.: '5270400'. + If the time since file creation is greater than the specified value, they will be processed by the script. + Default: '5270400' (61 day). - [Parameter(HelpMessage="Path to the file with exceptions. E.g.: 'C:\Data\exclude.txt'.")] - [Alias('E')][string]$Exclude = "$(Join-Path (Split-Path $PSScriptRoot -Parent) 'Vault.Exclude.txt')", + .PARAMETER LastWriteTime + Time since file modification (in seconds). E.g.: '5270400'. + If the time since file modification is greater than the specified value, they will be processed by the script. + Default: '5270400' (61 day). - [Parameter(HelpMessage="Path to the directory with logs. E.g.: 'C:\Data\Logs'.")] - [Alias('L')][string]$Logs = "$(Join-Path (Split-Path $PSScriptRoot -Parent) 'Logs')", + .PARAMETER FileSize + File size check. E.g.: '5kb' / '12mb'. + If the file size is greater than the specified value, they will be processed by the script. + Default: '0kb'. - [Parameter(HelpMessage="Removing empty directories.")] - [Alias('RD')][switch]$RemoveDirs = $false, + .PARAMETER Exclude + Path to the file with exceptions. E.g.: 'C:\Exclude.TXT'. + The values specified in this file will be ignored by the script. Wildcards are supported. + + .PARAMETER Logs + Path to the directory with logs. E.g.: 'C:\Logs'. + + .PARAMETER RemoveDirs + Removing empty directories. + Default: 'false'. + + .PARAMETER Overwrite + Overwrite existing files in Vault. + Default: 'false'. - [Parameter(HelpMessage="Overwrite existing files in Vault.")] + .EXAMPLE + Start-Vault -Source 'C:\Source' -Vault 'D:\Vault' + + .EXAMPLE + Start-Vault -Source 'C:\Source' -Vault 'D:\Vault' -CreationTime '864000' -LastWriteTime '864000' + + .EXAMPLE + Start-Vault -Source 'C:\Source' -Vault 'D:\Vault' -CreationTime '864000' -LastWriteTime '864000' -FileSize '32mb' + #> + + param( + [ValidateSet('CP', 'MV', 'RM')][Alias('M')][string]$Mode = 'MV', + [Parameter(Mandatory)][Alias('SRC')][string]$Source, + [Parameter(Mandatory)][Alias('DST')][string]$Vault, + [Alias('CT')][long]$CreationTime = 5270400, + [Alias('WT')][long]$LastWriteTime = $CreationTime, + [Alias('FS')][string]$FileSize = '0kb', + [Alias('E')][string]$Exclude = "$(Join-Path (Split-Path $PSScriptRoot -Parent) 'Vault.Exclude.txt')", + [Alias('L')][string]$Logs = "$(Join-Path (Split-Path $PSScriptRoot -Parent) 'Logs')", + [Alias('RD')][switch]$RemoveDirs = $false, [Alias('O')][switch]$Overwrite = $false )