return error if file being saved to /tmp is empty

This commit is contained in:
grumbulon 2023-02-04 17:18:18 -05:00 committed by Gitea
parent ae488eb7d2
commit 653670e6fa

View file

@ -10,6 +10,10 @@ func MakeLocal(filename, username string, buf []byte) error {
return fmt.Errorf("file %s already exists: %w", filename, err)
}
if len(buf) == 0 {
return fmt.Errorf("will not save empty file: %s to FS", filename)
}
f, err := os.Create("/tmp/tmpfile-" + filename + "-" + username) //nolint: gosec
// this is set to nolint because I am doing everything os.CreateTemp does but here since I don't like some of the limitations
if err != nil {