GODT-1381 Treat readonly folder as failure for cache on disk.

This commit is contained in:
Jakub
2021-11-29 12:00:01 +01:00
parent d7c5ace8e4
commit f30269865d
2 changed files with 20 additions and 4 deletions

View File

@ -23,6 +23,7 @@ import (
"crypto/rand"
"crypto/sha256"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
@ -60,6 +61,12 @@ func NewOnDiskCache(path string, cmp Compressor, opts Options) (Cache, error) {
return nil, err
}
file, err := ioutil.TempFile(path, "tmp")
if err != nil {
return nil, fmt.Errorf("cannot write to target: %w", err)
}
os.Remove(file.Name()) //nolint[errcheck]
usage := du.NewDiskUsage(path)
// NOTE(GODT-1158): use Available() or Free()?