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
93636260
Commit
93636260
authored
7 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Move validation of status into the ServiceStatus class.
parent
35553e56
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
AutoTx/AutoTx.cs
+6
-18
6 additions, 18 deletions
AutoTx/AutoTx.cs
AutoTx/XmlWrapper/ServiceStatus.cs
+29
-2
29 additions, 2 deletions
AutoTx/XmlWrapper/ServiceStatus.cs
with
35 additions
and
20 deletions
AutoTx/AutoTx.cs
+
6
−
18
View file @
93636260
...
...
@@ -146,7 +146,7 @@ namespace AutoTx
private
void
LoadStatusXml
()
{
try
{
writeLogDebug
(
"Trying to load status from "
+
_statusPath
);
_status
=
ServiceStatus
.
Deserialize
(
_statusPath
);
_status
=
ServiceStatus
.
Deserialize
(
_statusPath
,
_config
);
writeLogDebug
(
"Loaded status from "
+
_statusPath
);
}
catch
(
Exception
ex
)
{
...
...
@@ -170,22 +170,6 @@ namespace AutoTx
writeLog
(
"ERROR checking spooling directories (incoming / managed)!"
);
configInvalid
=
true
;
}
// CurrentTransferSrc
if
(
_status
.
CurrentTransferSrc
.
Length
>
0
&&
!
Directory
.
Exists
(
_status
.
CurrentTransferSrc
))
{
writeLog
(
"WARNING: status file contains non-existing source path of an "
+
"unfinished transfer: "
+
_status
.
CurrentTransferSrc
);
_status
.
CurrentTransferSrc
=
""
;
}
// CurrentTargetTmp
if
(
_status
.
CurrentTargetTmp
.
Length
>
0
&&
!
Directory
.
Exists
(
ExpandCurrentTargetTmp
()))
{
writeLog
(
"WARNING: status file contains non-existing temporary path of an "
+
"unfinished transfer: "
+
_status
.
CurrentTargetTmp
);
_status
.
CurrentTargetTmp
=
""
;
}
}
catch
(
Exception
ex
)
{
writeLog
(
"Error in CheckConfiguration(): "
+
ex
.
Message
+
" "
+
ex
.
StackTrace
);
...
...
@@ -285,7 +269,11 @@ namespace AutoTx
if
(!
string
.
IsNullOrEmpty
(
_config
.
ValidationWarnings
))
{
writeLog
(
"WARNING: some configuration settings might not be optimal:\n"
+
_config
.
ValidationWarnings
);
_config
.
ValidationWarnings
);
}
if
(!
string
.
IsNullOrEmpty
(
_status
.
ValidationWarnings
))
{
writeLog
(
"WARNING: some status parameters were invalid and have been reset:\n"
+
_status
.
ValidationWarnings
);
}
}
...
...
This diff is collapsed.
Click to expand it.
AutoTx/XmlWrapper/ServiceStatus.cs
+
29
−
2
View file @
93636260
...
...
@@ -7,7 +7,9 @@ namespace AutoTx.XmlWrapper
[
Serializable
]
public
class
ServiceStatus
{
[
NonSerialized
]
string
_storageFile
;
// remember where we came from
[
XmlIgnore
]
string
_storageFile
;
// remember where we came from
[
XmlIgnore
]
private
ServiceConfig
_config
;
[
XmlIgnore
]
public
string
ValidationWarnings
;
private
DateTime
_lastStatusUpdate
;
private
DateTime
_lastStorageNotification
;
...
...
@@ -154,8 +156,9 @@ namespace AutoTx.XmlWrapper
*/
}
public
static
ServiceStatus
Deserialize
(
string
file
)
{
public
static
ServiceStatus
Deserialize
(
string
file
,
ServiceConfig
config
)
{
ServiceStatus
status
;
var
xs
=
new
XmlSerializer
(
typeof
(
ServiceStatus
));
try
{
var
reader
=
File
.
OpenText
(
file
);
...
...
@@ -166,9 +169,33 @@ namespace AutoTx.XmlWrapper
// if reading the status XML fails, we return an empty (new) one
status
=
new
ServiceStatus
();
}
status
.
_config
=
config
;
ValidateStatus
(
status
);
// now set the storage filename:
status
.
_storageFile
=
file
;
return
status
;
}
private
static
void
ValidateStatus
(
ServiceStatus
s
)
{
// CurrentTransferSrc
if
(
s
.
CurrentTransferSrc
.
Length
>
0
&&
!
Directory
.
Exists
(
s
.
CurrentTransferSrc
))
{
s
.
ValidationWarnings
+=
" - found non-existing source path of an unfinished "
+
"transfer: "
+
s
.
CurrentTransferSrc
+
"\n"
;
s
.
CurrentTransferSrc
=
""
;
}
// CurrentTargetTmp
var
currentTargetTmpPath
=
Path
.
Combine
(
s
.
_config
.
DestinationDirectory
,
s
.
_config
.
TmpTransferDir
,
s
.
CurrentTargetTmp
);
if
(
s
.
CurrentTargetTmp
.
Length
>
0
&&
!
Directory
.
Exists
(
currentTargetTmpPath
))
{
s
.
ValidationWarnings
+=
" - found non-existing temporary path of an "
+
"unfinished transfer: "
+
currentTargetTmpPath
+
"\n"
;
s
.
CurrentTargetTmp
=
""
;
}
}
}
}
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