@@ -522,8 +522,8 @@ func handleAgentMessagePostResponse(incoming *map[string]interface{}, uUIDInfo *
522
522
logging .LogError (err , "Failed to write file to disk" )
523
523
} else {
524
524
fileMeta .Size = fileDisk .Size ()
525
- if fileMeta .Size >= POSTGRES_MAX_INT {
526
- fileMeta .Size = POSTGRES_MAX_INT - 1
525
+ if fileMeta .Size >= POSTGRES_MAX_BIGINT {
526
+ fileMeta .Size = POSTGRES_MAX_BIGINT - 1
527
527
}
528
528
}
529
529
if fileMeta .ChunksReceived >= fileMeta .TotalChunks {
@@ -998,6 +998,8 @@ func listenForWriteDownloadChunkToLocalDisk() {
998
998
if err != nil {
999
999
logging .LogFatalError (err , "Failed to create named statement for writing file chunks to disk" )
1000
1000
}
1001
+ syncChunksTimerDuration := 5 * time .Second
1002
+ syncChunksTimer := time .NewTimer (syncChunksTimerDuration )
1001
1003
for {
1002
1004
select {
1003
1005
case agentResponse := <- writeDownloadChunkToDiskChan :
@@ -1065,7 +1067,7 @@ func listenForWriteDownloadChunkToLocalDisk() {
1065
1067
Success : true ,
1066
1068
ChunksReceived : newChunks [agentResponse .LocalMythicPath ].Chunks ,
1067
1069
}
1068
- case <- time .After (2 * time .Second ):
1070
+ case <- time .After (1 * time .Second ):
1069
1071
for key , f := range openFiles {
1070
1072
f .Sync ()
1071
1073
f .Close ()
@@ -1076,6 +1078,14 @@ func listenForWriteDownloadChunkToLocalDisk() {
1076
1078
}
1077
1079
delete (newChunks , key )
1078
1080
}
1081
+ case <- syncChunksTimer .C :
1082
+ for key , _ := range openFiles {
1083
+ _ , err = updateChunksStatement .Exec (newChunks [key ].FileMetaID , newChunks [key ].Chunks )
1084
+ if err != nil {
1085
+ logging .LogError (err , "failed to update chunk count for file" )
1086
+ }
1087
+ }
1088
+ syncChunksTimer .Reset (syncChunksTimerDuration )
1079
1089
}
1080
1090
}
1081
1091
}
0 commit comments