Append options for PeriodicFileSystemWatcher

pull/1/head
unknown 4 years ago
parent f520eab6bb
commit 4d0d77bd62

@ -18,9 +18,12 @@ namespace ZeroLevel.Services.FileSystem
public event Action OnCompleteMovingFilesToTemporary = delegate { }; public event Action OnCompleteMovingFilesToTemporary = delegate { };
private readonly bool _autoRemoveTempFileAfterCallback = false; private readonly bool _autoRemoveTempFileAfterCallback = false;
private readonly bool _useSubdirectories = false;
public PeriodicFileSystemWatcher(TimeSpan period, string watch_folder, string temp_folder, Action<FileMeta> callback, bool removeTempFileAfterCallback = false) public PeriodicFileSystemWatcher(TimeSpan period, string watch_folder, string temp_folder, Action<FileMeta> callback
{ , bool removeTempFileAfterCallback = false
, bool useSubdirectories = false)
{
if (string.IsNullOrWhiteSpace(watch_folder)) if (string.IsNullOrWhiteSpace(watch_folder))
{ {
throw new ArgumentNullException(nameof(watch_folder)); throw new ArgumentNullException(nameof(watch_folder));
@ -29,6 +32,7 @@ namespace ZeroLevel.Services.FileSystem
{ {
throw new ArgumentNullException(nameof(callback)); throw new ArgumentNullException(nameof(callback));
} }
_useSubdirectories = useSubdirectories;
_autoRemoveTempFileAfterCallback = removeTempFileAfterCallback; _autoRemoveTempFileAfterCallback = removeTempFileAfterCallback;
_callback = callback; _callback = callback;
_sourceFolder = watch_folder; _sourceFolder = watch_folder;
@ -168,7 +172,7 @@ namespace ZeroLevel.Services.FileSystem
/// </summary> /// </summary>
private string[] GetFilesFromSource() private string[] GetFilesFromSource()
{ {
string[] files = Directory.GetFiles(_sourceFolder, "*.*", SearchOption.TopDirectoryOnly); string[] files = Directory.GetFiles(_sourceFolder, "*.*", _useSubdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
Array.Sort<string>(files, FileNameSortCompare); Array.Sort<string>(files, FileNameSortCompare);
return files; return files;
} }

@ -6,16 +6,16 @@
</Description> </Description>
<Authors>ogoun</Authors> <Authors>ogoun</Authors>
<Company>ogoun</Company> <Company>ogoun</Company>
<AssemblyVersion>3.3.4.3</AssemblyVersion> <AssemblyVersion>3.3.4.4</AssemblyVersion>
<PackageReleaseNotes>Refactoring</PackageReleaseNotes> <PackageReleaseNotes>Additional options for PeriodicFileSystemWatcher</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/ogoun/Zero/wiki</PackageProjectUrl> <PackageProjectUrl>https://github.com/ogoun/Zero/wiki</PackageProjectUrl>
<Copyright>Copyright Ogoun 2020</Copyright> <Copyright>Copyright Ogoun 2020</Copyright>
<PackageLicenseUrl></PackageLicenseUrl> <PackageLicenseUrl></PackageLicenseUrl>
<PackageIconUrl></PackageIconUrl> <PackageIconUrl></PackageIconUrl>
<RepositoryUrl>https://github.com/ogoun/Zero</RepositoryUrl> <RepositoryUrl>https://github.com/ogoun/Zero</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType> <RepositoryType>GitHub</RepositoryType>
<Version>3.3.4.3</Version> <Version>3.3.4.4</Version>
<FileVersion>3.3.4.3</FileVersion> <FileVersion>3.3.4.4</FileVersion>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<PackageIcon>zero.png</PackageIcon> <PackageIcon>zero.png</PackageIcon>
</PropertyGroup> </PropertyGroup>

Loading…
Cancel
Save

Powered by TurnKey Linux.