mirror of
https://github.com/usememos/memos.git
synced 2024-12-19 00:51:30 +03:00
chore: add available generator amount flag (#1696)
This commit is contained in:
parent
467f9080a1
commit
ba8e1e5dc2
@ -501,12 +501,22 @@ func replacePathTemplate(path string, filename string) string {
|
||||
return path
|
||||
}
|
||||
|
||||
var availableGeneratorAmount = 32
|
||||
|
||||
func getOrGenerateThumbnailImage(srcBlob []byte, dstPath string) ([]byte, error) {
|
||||
if _, err := os.Stat(dstPath); err != nil {
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
return nil, errors.Wrap(err, "failed to check thumbnail image stat")
|
||||
}
|
||||
|
||||
if availableGeneratorAmount <= 0 {
|
||||
return nil, errors.New("not enough available generator amount")
|
||||
}
|
||||
availableGeneratorAmount--
|
||||
defer func() {
|
||||
availableGeneratorAmount++
|
||||
}()
|
||||
|
||||
reader := bytes.NewReader(srcBlob)
|
||||
src, err := imaging.Decode(reader)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user