Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
auto-tx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vamp
auto-tx
Commits
43c621db
Commit
43c621db
authored
7 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Add block comments to denote sequence of validation checks.
parent
7dc0494d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ATxCommon/Serializables/ServiceConfig.cs
+12
-2
12 additions, 2 deletions
ATxCommon/Serializables/ServiceConfig.cs
with
12 additions
and
2 deletions
ATxCommon/Serializables/ServiceConfig.cs
+
12
−
2
View file @
43c621db
...
@@ -351,6 +351,7 @@ namespace ATxCommon.Serializables
...
@@ -351,6 +351,7 @@ namespace ATxCommon.Serializables
throw
new
ConfigurationErrorsException
(
msg
);
throw
new
ConfigurationErrorsException
(
msg
);
}
}
// check if all required parameters are there and non-empty / non-zero:
errmsg
+=
CheckEmpty
(
c
.
HostAlias
,
nameof
(
c
.
HostAlias
));
errmsg
+=
CheckEmpty
(
c
.
HostAlias
,
nameof
(
c
.
HostAlias
));
errmsg
+=
CheckEmpty
(
c
.
SourceDrive
,
nameof
(
c
.
SourceDrive
));
errmsg
+=
CheckEmpty
(
c
.
SourceDrive
,
nameof
(
c
.
SourceDrive
));
errmsg
+=
CheckEmpty
(
c
.
IncomingDirectory
,
nameof
(
c
.
IncomingDirectory
));
errmsg
+=
CheckEmpty
(
c
.
IncomingDirectory
,
nameof
(
c
.
IncomingDirectory
));
...
@@ -363,11 +364,14 @@ namespace ATxCommon.Serializables
...
@@ -363,11 +364,14 @@ namespace ATxCommon.Serializables
errmsg
+=
CheckMinValue
(
c
.
MaxCpuUsage
,
nameof
(
c
.
MaxCpuUsage
),
5
);
errmsg
+=
CheckMinValue
(
c
.
MaxCpuUsage
,
nameof
(
c
.
MaxCpuUsage
),
5
);
errmsg
+=
CheckMinValue
(
c
.
MinAvailableMemory
,
nameof
(
c
.
MinAvailableMemory
),
256
);
errmsg
+=
CheckMinValue
(
c
.
MinAvailableMemory
,
nameof
(
c
.
MinAvailableMemory
),
256
);
// if any of the
above detected invalid settings
we terminate now as many of the
// if any of the
required parameter checks failed
we terminate now as many of the
// string checks below would fail on empty strings:
// string checks below would fail on empty strings:
if
(!
string
.
IsNullOrWhiteSpace
(
errmsg
))
if
(!
string
.
IsNullOrWhiteSpace
(
errmsg
))
LogAndThrow
(
errmsg
);
LogAndThrow
(
errmsg
);
////////// REQUIRED PARAMETERS SETTINGS VALIDATION //////////
// SourceDrive
// SourceDrive
if
(
c
.
SourceDrive
.
Substring
(
1
)
!=
@":\"
)
if
(
c
.
SourceDrive
.
Substring
(
1
)
!=
@":\"
)
errmsg
+=
"SourceDrive must be of form [X:\\]\n!"
;
errmsg
+=
"SourceDrive must be of form [X:\\]\n!"
;
...
@@ -388,16 +392,22 @@ namespace ATxCommon.Serializables
...
@@ -388,16 +392,22 @@ namespace ATxCommon.Serializables
if
(!
Directory
.
Exists
(
tmpTransferPath
))
if
(!
Directory
.
Exists
(
tmpTransferPath
))
errmsg
+=
$"can't find (or reach) temporary transfer dir:
{
tmpTransferPath
}
\n"
;
errmsg
+=
$"can't find (or reach) temporary transfer dir:
{
tmpTransferPath
}
\n"
;
////////// OPTIONAL PARAMETERS SETTINGS VALIDATION //////////
// DriveName
// DriveName
foreach
(
var
driveToCheck
in
c
.
SpaceMonitoring
)
{
foreach
(
var
driveToCheck
in
c
.
SpaceMonitoring
)
{
errmsg
+=
CheckLocalDrive
(
driveToCheck
.
DriveName
,
nameof
(
driveToCheck
.
DriveName
));
errmsg
+=
CheckLocalDrive
(
driveToCheck
.
DriveName
,
nameof
(
driveToCheck
.
DriveName
));
}
}
// NON-CRITICAL stuff is simply reported to the logs:
////////// WEAK CHECKS ON PARAMETERS SETTINGS //////////
// those checks are non-critical and are simply reported to the logs
if
(!
c
.
DestinationDirectory
.
StartsWith
(
@"\\"
))
if
(!
c
.
DestinationDirectory
.
StartsWith
(
@"\\"
))
SubOptimal
(
"DestinationDirectory"
,
c
.
DestinationDirectory
,
"is not a UNC path!"
);
SubOptimal
(
"DestinationDirectory"
,
c
.
DestinationDirectory
,
"is not a UNC path!"
);
if
(
string
.
IsNullOrWhiteSpace
(
errmsg
))
if
(
string
.
IsNullOrWhiteSpace
(
errmsg
))
return
;
return
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment