mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
media: use cache directory for temp files
This commit is contained in:
parent
420a7dab4e
commit
704fe45eb9
2 changed files with 6 additions and 1 deletions
|
@ -53,6 +53,7 @@ type Gomuks struct {
|
||||||
ConfigDir string
|
ConfigDir string
|
||||||
DataDir string
|
DataDir string
|
||||||
CacheDir string
|
CacheDir string
|
||||||
|
TempDir string
|
||||||
LogDir string
|
LogDir string
|
||||||
|
|
||||||
stopOnce sync.Once
|
stopOnce sync.Once
|
||||||
|
@ -133,8 +134,12 @@ func (gmx *Gomuks) LoadConfig() {
|
||||||
gmx.LogDir = filepath.Join(homeDir, ".local", "state", "gomuks")
|
gmx.LogDir = filepath.Join(homeDir, ".local", "state", "gomuks")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if gmx.TempDir = os.Getenv("GOMUKS_TMPDIR"); gmx.TempDir == "" {
|
||||||
|
gmx.TempDir = filepath.Join(gmx.CacheDir, "tmp")
|
||||||
|
}
|
||||||
exerrors.PanicIfNotNil(os.MkdirAll(gmx.ConfigDir, 0700))
|
exerrors.PanicIfNotNil(os.MkdirAll(gmx.ConfigDir, 0700))
|
||||||
exerrors.PanicIfNotNil(os.MkdirAll(gmx.CacheDir, 0700))
|
exerrors.PanicIfNotNil(os.MkdirAll(gmx.CacheDir, 0700))
|
||||||
|
exerrors.PanicIfNotNil(os.MkdirAll(gmx.TempDir, 0700))
|
||||||
exerrors.PanicIfNotNil(os.MkdirAll(gmx.DataDir, 0700))
|
exerrors.PanicIfNotNil(os.MkdirAll(gmx.DataDir, 0700))
|
||||||
exerrors.PanicIfNotNil(os.MkdirAll(gmx.LogDir, 0700))
|
exerrors.PanicIfNotNil(os.MkdirAll(gmx.LogDir, 0700))
|
||||||
}
|
}
|
||||||
|
|
2
media.go
2
media.go
|
@ -106,7 +106,7 @@ func (gmx *Gomuks) DownloadMedia(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tempFile, err := os.CreateTemp("", "gomuks-download-*")
|
tempFile, err := os.CreateTemp(gmx.TempDir, "download-*")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Err(err).Msg("Failed to create temporary file")
|
log.Err(err).Msg("Failed to create temporary file")
|
||||||
mautrix.MUnknown.WithMessage(fmt.Sprintf("Failed to create temp file: %v", err)).Write(w)
|
mautrix.MUnknown.WithMessage(fmt.Sprintf("Failed to create temp file: %v", err)).Write(w)
|
||||||
|
|
Loading…
Add table
Reference in a new issue