Skip to content

Commit

Permalink
throw error if checkpointing missing file
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Jansson <andreas@replicate.ai>
  • Loading branch information
andreasjansson committed Mar 9, 2021
1 parent 9ca217e commit 524ccd9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions go/pkg/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ func CopyToTempDir(localPath string, includePath string) (tempDir string, err er
// then copy the ones that match the includePath.
// TODO(andreas): only scan files in the includePath
filesToCopy, err := getListOfFilesToPut(localPath, tempDir)
if err != nil {
return "", err
}
count := 0
for _, file := range filesToCopy {

Expand Down Expand Up @@ -424,6 +427,10 @@ func CopyToTempDir(localPath string, includePath string) (tempDir string, err er
count += 1
}

if count == 0 {
return "", fmt.Errorf("No files matched '%s' in %s", includePath, localPath)
}

console.Debug("Copied %d files to temporary directory (took %.3f seconds)", count, time.Since(start).Seconds())

return tempDir, err
Expand Down
4 changes: 4 additions & 0 deletions go/pkg/repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,8 @@ func TestCopyToTempDir(t *testing.T) {
contents, err = ioutil.ReadFile(path.Join(tempDir, "my/folder/bar"))
require.NoError(t, err)
require.Equal(t, "bar", string(contents))

// with missing file
tempDir, err = CopyToTempDir(dir, "not-existing")
require.Error(t, err)
}

0 comments on commit 524ccd9

Please sign in to comment.