Skip to content

Commit 37fcbd0

Browse files
committedMar 5, 2025
updating file size to bigint to track larger files properly
1 parent ef4637e commit 37fcbd0

File tree

6 files changed

+30
-6
lines changed

6 files changed

+30
-6
lines changed
 

‎CHANGELOG.MD

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [3.3.1-rc49] - 2025-03-05
8+
9+
### Changed
10+
11+
- Updated the `size` field in `filemeta` to `bigint` instead of `int` for larger file size tracking
12+
- Added a timer to sync chunk counts every 5s
13+
714
## [3.3.1-rc48] - 2025-03-05
815

916
### Changed

‎VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.1-rc48
1+
3.3.1-rc49

‎mythic-docker/src/VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.1-rc48
1+
3.3.1-rc49

‎mythic-docker/src/database/initialize.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
var DB *sqlx.DB
16-
var currentMigrationVersion int64 = 3003005
16+
var currentMigrationVersion int64 = 3003006
1717

1818
// initial structs made with './tables-to-go -u mythic_user -p [password here] -h [ip here] -v -d mythic_db -of output -pn database_structs'
1919
// package pulled from https://github.com/fraenky8/tables-to-go
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- +migrate Up
2+
-- SQL in section 'Up' is executed when this migration is applied
3+
alter table "public"."filemeta" alter column "size" TYPE BIGINT;
4+
-- +migrate Down
5+
-- SQL in section 'Down' is executed when this migration is rolled back
6+
7+

‎mythic-docker/src/rabbitmq/util_agent_message_actions_post_response.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,8 @@ func handleAgentMessagePostResponse(incoming *map[string]interface{}, uUIDInfo *
522522
logging.LogError(err, "Failed to write file to disk")
523523
} else {
524524
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
527527
}
528528
}
529529
if fileMeta.ChunksReceived >= fileMeta.TotalChunks {
@@ -998,6 +998,8 @@ func listenForWriteDownloadChunkToLocalDisk() {
998998
if err != nil {
999999
logging.LogFatalError(err, "Failed to create named statement for writing file chunks to disk")
10001000
}
1001+
syncChunksTimerDuration := 5 * time.Second
1002+
syncChunksTimer := time.NewTimer(syncChunksTimerDuration)
10011003
for {
10021004
select {
10031005
case agentResponse := <-writeDownloadChunkToDiskChan:
@@ -1065,7 +1067,7 @@ func listenForWriteDownloadChunkToLocalDisk() {
10651067
Success: true,
10661068
ChunksReceived: newChunks[agentResponse.LocalMythicPath].Chunks,
10671069
}
1068-
case <-time.After(2 * time.Second):
1070+
case <-time.After(1 * time.Second):
10691071
for key, f := range openFiles {
10701072
f.Sync()
10711073
f.Close()
@@ -1076,6 +1078,14 @@ func listenForWriteDownloadChunkToLocalDisk() {
10761078
}
10771079
delete(newChunks, key)
10781080
}
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)
10791089
}
10801090
}
10811091
}

0 commit comments

Comments
 (0)