Skip to content

Commit

Permalink
Allow disabling of hash checking
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Sep 26, 2023
1 parent 4e32f42 commit 8165728
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions archives/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ type Config struct {
AWSAccessKeyID string `help:"the access key id to use when authenticating S3"`
AWSSecretAccessKey string `help:"the secret access key id to use when authenticating S3"`

TempDir string `help:"directory where temporary archive files are written"`
KeepFiles bool `help:"whether we should keep local archive files after upload (default false)"`
UploadToS3 bool `help:"whether we should upload archive to S3"`
TempDir string `help:"directory where temporary archive files are written"`
KeepFiles bool `help:"whether we should keep local archive files after upload (default false)"`
UploadToS3 bool `help:"whether we should upload archive to S3"`
CheckS3Hashes bool `help:"whether to check S3 hashes of uploaded archives before deleting records"`

ArchiveMessages bool `help:"whether we should archive messages"`
ArchiveRuns bool `help:"whether we should archive runs"`
Expand Down Expand Up @@ -50,9 +51,10 @@ func NewDefaultConfig() *Config {
AWSAccessKeyID: "",
AWSSecretAccessKey: "",

TempDir: "/tmp",
KeepFiles: false,
UploadToS3: true,
TempDir: "/tmp",
KeepFiles: false,
UploadToS3: true,
CheckS3Hashes: true,

ArchiveMessages: true,
ArchiveRuns: true,
Expand Down
2 changes: 1 addition & 1 deletion archives/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func DeleteArchivedMessages(ctx context.Context, config *Config, db *sqlx.DB, s3
}

Check warning on line 140 in archives/messages.go

View check run for this annotation

Codecov / codecov/patch

archives/messages.go#L139-L140

Added lines #L139 - L140 were not covered by tests

// if S3 hash is MD5 then check against archive hash
if archive.Size <= maxSingleUploadBytes && s3Hash != archive.Hash {
if config.CheckS3Hashes && archive.Size <= maxSingleUploadBytes && s3Hash != archive.Hash {
return fmt.Errorf("archive md5: %s and s3 etag: %s do not match", archive.Hash, s3Hash)

Check warning on line 144 in archives/messages.go

View check run for this annotation

Codecov / codecov/patch

archives/messages.go#L144

Added line #L144 was not covered by tests
}

Expand Down
2 changes: 1 addition & 1 deletion archives/runs.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func DeleteArchivedRuns(ctx context.Context, config *Config, db *sqlx.DB, s3Clie
}

Check warning on line 135 in archives/runs.go

View check run for this annotation

Codecov / codecov/patch

archives/runs.go#L134-L135

Added lines #L134 - L135 were not covered by tests

// if S3 hash is MD5 then check against archive hash
if archive.Size <= maxSingleUploadBytes && s3Hash != archive.Hash {
if config.CheckS3Hashes && archive.Size <= maxSingleUploadBytes && s3Hash != archive.Hash {
return fmt.Errorf("archive md5: %s and s3 etag: %s do not match", archive.Hash, s3Hash)

Check warning on line 139 in archives/runs.go

View check run for this annotation

Codecov / codecov/patch

archives/runs.go#L139

Added line #L139 was not covered by tests
}

Expand Down

0 comments on commit 8165728

Please sign in to comment.