Fix unnecessary log messages to avoid flooding the logs (#5900)

This commit is contained in:
Krishna Srinivas
2018-05-08 19:09:15 -07:00
committed by Harshavardhana
parent 9de8fefa90
commit bb34bd91f1
6 changed files with 63 additions and 16 deletions

View File

@@ -225,6 +225,15 @@ func fsStatDir(ctx context.Context, statDir string) (os.FileInfo, error) {
return fi, nil
}
// Returns if the dirPath is a directory.
func fsIsDir(ctx context.Context, dirPath string) bool {
fi, err := fsStat(ctx, dirPath)
if err != nil {
return false
}
return fi.IsDir()
}
// Lookup if file exists, returns file attributes upon success.
func fsStatFile(ctx context.Context, statFile string) (os.FileInfo, error) {
fi, err := fsStat(ctx, statFile)
@@ -242,6 +251,15 @@ func fsStatFile(ctx context.Context, statFile string) (os.FileInfo, error) {
return fi, nil
}
// Returns if the filePath is a regular file.
func fsIsFile(ctx context.Context, filePath string) bool {
fi, err := fsStat(ctx, filePath)
if err != nil {
return false
}
return fi.Mode().IsRegular()
}
// Opens the file at given path, optionally from an offset. Upon success returns
// a readable stream and the size of the readable stream.
func fsOpenFile(ctx context.Context, readPath string, offset int64) (io.ReadCloser, int64, error) {
@@ -402,7 +420,9 @@ func fsDeleteFile(ctx context.Context, basePath, deletePath string) error {
}
if err := deleteFile(basePath, deletePath); err != nil {
logger.LogIf(ctx, err)
if err != errFileNotFound {
logger.LogIf(ctx, err)
}
return err
}
return nil