Skip to content

Commit

Permalink
fix: handle deletion of queries file (#4370)
Browse files Browse the repository at this point in the history
Builds would fail if all queries were removed because marking a file as
changed within the build assumed the file still existed.
  • Loading branch information
matt2e authored Feb 11, 2025
1 parent 96e98f0 commit bbf0d7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go-runtime/compile/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ func scaffoldBuildTemplateAndTidy(ctx context.Context, config moduleconfig.AbsMo
return fmt.Errorf("failed to delete %s: %w", ftlQueriesFilename, err)
}
if err := filesTransaction.ModifiedFiles(filepath.Join(config.Dir, ftlQueriesFilename)); err != nil {
return fmt.Errorf("failed to mark %s as modified: %w", ftlQueriesFilename, err)
return fmt.Errorf("failed to mark %s as deleted: %w", ftlQueriesFilename, err)
}
}
if err := filesTransaction.ModifiedFiles(filepath.Join(config.Dir, ftlTypesFilename)); err != nil {
Expand Down
5 changes: 5 additions & 0 deletions internal/watch/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package watch

import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -274,6 +275,10 @@ func (t *modifyFilesTransaction) ModifiedFiles(paths ...string) error {
}

for _, path := range paths {
if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {
delete(moduleHashes.Hashes, path)
continue
}
hash, matched, err := computeFileHash(moduleHashes.Config.Dir, path, t.watcher.patterns)
if err != nil {
return err
Expand Down

0 comments on commit bbf0d7a

Please sign in to comment.