Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FIT-Connect-SDK - .NET
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FIT-Connect
FIT-Connect-SDK - .NET
Commits
f136099a
Commit
f136099a
authored
7 months ago
by
Klaus Fischer
Browse files
Options
Downloads
Patches
Plain Diff
WIP: resolve warnings
parent
28cfdb89
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!125
Feature/1522 chunking
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
FitConnect/Subscriber.cs
+16
-8
16 additions, 8 deletions
FitConnect/Subscriber.cs
with
16 additions
and
8 deletions
FitConnect/Subscriber.cs
+
16
−
8
View file @
f136099a
...
...
@@ -76,7 +76,7 @@ public class Subscriber : FitConnectClient, IReceivedSubmission,
if
(
Submission
?.
Id
==
null
||
Submission
?.
Metadata
==
null
)
throw
new
Exception
(
"No submission available"
);
var
attachments
=
Submission
.
Attachments
;
var
attachments
=
Submission
.
Attachments
;
return
attachments
??
new
List
<
Attachment
>();
}
catch
(
Exception
e
)
{
...
...
@@ -509,7 +509,12 @@ public class Subscriber : FitConnectClient, IReceivedSubmission,
:
(
JsonConvert
.
DeserializeObject
(
jsonString
)
as
JObject
)?[
"$schema"
]?.
ToString
();
}
private
record
DownloadedAttachment
(
Guid
Id
,
byte
[]?
Content
,
byte
[]
Hash
,
string
?
Filename
,
string
AuthenticationTag
)
{
private
record
DownloadedAttachment
(
Guid
Id
,
byte
[]?
Content
,
byte
[]
Hash
,
string
?
Filename
,
string
AuthenticationTag
)
{
public
DataHash
GetAttachmentHash
()
{
if
(
Content
!=
null
)
return
FitEncryption
.
CalculateHash
(
Content
);
...
...
@@ -558,12 +563,14 @@ public class Subscriber : FitConnectClient, IReceivedSubmission,
(
_
,
content
,
hash
)
=
Encryption
.
Decrypt
(
encryptedAttachment
);
string
?
filename
=
null
;
if
(
isFragment
)
{
if
(
container
==
null
)
throw
new
FitConnectSubscriberException
(
"Attachment is fragment but container is null"
);
var
path
=
Path
.
Combine
(
TempFilePath
,
submission
.
SubmissionId
.
ToString
(),
container
.
AttachmentId
.
ToString
());
Directory
.
CreateDirectory
(
path
);
filename
=
Path
.
Combine
(
path
,
$"downloaded.
{
index
:
0000
}
"
);
await
File
.
WriteAllBytesAsync
(
filename
,
content
);
// continue;
}
downloaded
.
Add
(
new
DownloadedAttachment
(
id
,
content
,
hash
,
filename
,
authenticationTag
));
...
...
@@ -592,8 +599,8 @@ public class Subscriber : FitConnectClient, IReceivedSubmission,
}
private
Dictionary
<
Guid
,
string
>
CombineLargeAttachments
(
Submission
submission
,
List
<
DownloadedAttachment
>
downloaded
)
{
private
Dictionary
<
Guid
,
string
>
CombineLargeAttachments
(
Submission
submission
,
List
<
DownloadedAttachment
>
downloaded
)
{
Dictionary
<
Guid
,
string
>
authenticationTags
=
new
();
var
largeAttachments
=
submission
.
Metadata
?.
ContentStructure
.
Attachments
?.
Where
(
a
=>
a
.
Fragments
!=
null
)
?.
ToList
();
...
...
@@ -602,7 +609,8 @@ public class Subscriber : FitConnectClient, IReceivedSubmission,
foreach
(
var
largeAttachment
in
largeAttachments
)
{
var
fragments
=
largeAttachment
.
Fragments
.
Select
(
f
=>
downloaded
.
First
(
d
=>
d
.
Id
==
f
)).
ToList
();
var
filenames
=
fragments
.
OrderBy
(
f
=>
f
.
Filename
).
Where
(
f
=>
f
.
Filename
!=
null
).
Select
(
f
=>
f
.
Filename
).
ToList
();
var
filenames
=
fragments
.
OrderBy
(
f
=>
f
.
Filename
).
Where
(
f
=>
f
.
Filename
!=
null
).
Select
(
f
=>
f
.
Filename
)
.
ToList
();
if
(
filenames
.
Any
(
f
=>
f
==
null
))
throw
new
FitConnectSubscriberException
(
"Filename in the fragments is null"
);
...
...
@@ -617,6 +625,7 @@ public class Subscriber : FitConnectClient, IReceivedSubmission,
downloaded
.
Add
(
new
DownloadedAttachment
(
largeAttachment
.
AttachmentId
,
null
,
hash
,
attachmentPath
,
""
));
authenticationTags
.
Add
(
largeAttachment
.
AttachmentId
,
""
);
}
return
authenticationTags
;
}
...
...
@@ -864,7 +873,6 @@ public class Subscriber : FitConnectClient, IReceivedSubmission,
/// <exception cref="SecurityEventException"></exception>
private
async
Task
CheckAttachments
(
Submission
submission
,
SecurityEventToken
submitEvent
)
{
if
(
submission
?.
Attachments
!=
null
)
{
// @formatter:off
...
...
@@ -945,4 +953,4 @@ public interface IReceivedReply : ISubmissionBody {
public
Metadata
Metadata
{
get
;
set
;
}
public
AuthenticationTags
AuthenticationInformation
{
get
;
set
;
}
}
}
\ No newline at end of file
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