Skip to content

Commit

Permalink
Merge pull request #304 from bcc-code/chore/fix-non-determinism
Browse files Browse the repository at this point in the history
Chore/fix non determinism
  • Loading branch information
KillerX authored Aug 15, 2024
2 parents 1019b54 + b310e79 commit 9208d19
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.PHONY: test

test:
go vet ./...
go test -race ./...
5 changes: 1 addition & 4 deletions workflows/export/prepare_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ func resolutionToString(r Resolution) resolutionString {
func resolutionFromString(str resolutionString) Resolution {
var r Resolution

_, err := fmt.Sscanf(string(str), "%dx%d-%t", &r.Width, &r.Height, &r.File)
if err != nil {
fmt.Sprintf("Failed to parse resolution string %s, err: %s", str, err.Error())
}
_, _ = fmt.Sscanf(string(str), "%dx%d-%t", &r.Width, &r.Height, &r.File)

r.EnsureEven()
return r
Expand Down
7 changes: 5 additions & 2 deletions workflows/misc/cleanup_production.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type SortFilesByImportedDateParams struct {
//
// This workflow is intentionally not registered anywhere, as it is not meant to be used in normal day-to-day operations
// without modification and testing.
//
//workflowcheck:ignore
func SortFilesByImportedDate(
ctx workflow.Context,
params SortFilesByImportedDateParams,
Expand All @@ -43,7 +45,7 @@ func SortFilesByImportedDate(
cnt := 1
total := len(params.FileList)
failed := map[string]error{}
start := time.Now()
start := workflow.Now(ctx)

if params.BatchSize < 1 {
params.BatchSize = 1
Expand All @@ -52,7 +54,8 @@ func SortFilesByImportedDate(
filesChan := lo.SliceToChannel(params.BatchSize, params.FileList)

for {
items, _, _, ok := lo.Buffer(filesChan, params.BatchSize)
items, _, _, ok := lo.Buffer[string](filesChan, params.BatchSize)

if !ok {
break
}
Expand Down
9 changes: 8 additions & 1 deletion workflows/scheduled/files_cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ func CleanupTemp(ctx workflow.Context) (*CleanupResult, error) {

deletedFiles := []string{}

for folder, olderThan := range foldersToCleanup {
folders, err := wfutils.GetMapKeysSafely(ctx, foldersToCleanup)
if err != nil {
return nil, err
}

for _, folder := range folders {
olderThan := foldersToCleanup[folder]

deletedFilesLoop := []string{}
err := wfutils.ExecuteWithLowPrioQueue(ctx, activities.Util.DeleteOldFiles, activities.CleanupInput{
Root: paths.MustParse(folder),
Expand Down

0 comments on commit 9208d19

Please sign in to comment.