TemporaryDirectoryForBigFiles returns a directory for temporary (big) files. On non Windows systems it avoids the use of os.TempDir(), because the default temporary directory usually falls under /tmp which on systemd based systems could be the unsuitable tmpfs filesystem.
(sys *types.SystemContext)
| 23 | // On non Windows systems it avoids the use of os.TempDir(), because the default temporary directory usually falls under /tmp |
| 24 | // which on systemd based systems could be the unsuitable tmpfs filesystem. |
| 25 | func temporaryDirectoryForBigFiles(sys *types.SystemContext) string { |
| 26 | if sys != nil && sys.BigFilesTemporaryDir != "" { |
| 27 | return sys.BigFilesTemporaryDir |
| 28 | } |
| 29 | var temporaryDirectoryForBigFiles string |
| 30 | if runtime.GOOS == "windows" { |
| 31 | temporaryDirectoryForBigFiles = os.TempDir() |
| 32 | } else { |
| 33 | temporaryDirectoryForBigFiles = unixTempDirForBigFiles |
| 34 | } |
| 35 | return temporaryDirectoryForBigFiles |
| 36 | } |
| 37 | |
| 38 | func CreateBigFileTemp(sys *types.SystemContext, name string) (*os.File, error) { |
| 39 | return os.CreateTemp(temporaryDirectoryForBigFiles(sys), prefix+name) |
no outgoing calls
no test coverage detected
searching dependent graphs…