diff --git a/archives/config.go b/archives/config.go index ad001d2..596b56e 100644 --- a/archives/config.go +++ b/archives/config.go @@ -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"` @@ -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, diff --git a/archives/messages.go b/archives/messages.go index 4c3f592..d45b711 100644 --- a/archives/messages.go +++ b/archives/messages.go @@ -140,7 +140,7 @@ func DeleteArchivedMessages(ctx context.Context, config *Config, db *sqlx.DB, s3 } // 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) } diff --git a/archives/runs.go b/archives/runs.go index 304c8da..9a35957 100644 --- a/archives/runs.go +++ b/archives/runs.go @@ -135,7 +135,7 @@ func DeleteArchivedRuns(ctx context.Context, config *Config, db *sqlx.DB, s3Clie } // 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) }