Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
0cea5eba
Unverified
Commit
0cea5eba
authored
May 22, 2023
by
Athurg Gooth
Committed by
GitHub
May 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: concurrent counter operates (#1706)
Co-authored-by:
Athurg Feng
<
athurg@gooth.org
>
parent
1e4a867a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
resource.go
server/resource.go
+5
-4
No files found.
server/resource.go
View file @
0cea5eba
...
@@ -13,6 +13,7 @@ import (
...
@@ -13,6 +13,7 @@ import (
"regexp"
"regexp"
"strconv"
"strconv"
"strings"
"strings"
"sync/atomic"
"time"
"time"
"github.com/disintegration/imaging"
"github.com/disintegration/imaging"
...
@@ -501,7 +502,7 @@ func replacePathTemplate(path string, filename string) string {
...
@@ -501,7 +502,7 @@ func replacePathTemplate(path string, filename string) string {
return
path
return
path
}
}
var
availableGeneratorAmount
=
32
var
availableGeneratorAmount
int32
=
32
func
getOrGenerateThumbnailImage
(
srcBlob
[]
byte
,
dstPath
string
)
([]
byte
,
error
)
{
func
getOrGenerateThumbnailImage
(
srcBlob
[]
byte
,
dstPath
string
)
([]
byte
,
error
)
{
if
_
,
err
:=
os
.
Stat
(
dstPath
);
err
!=
nil
{
if
_
,
err
:=
os
.
Stat
(
dstPath
);
err
!=
nil
{
...
@@ -509,12 +510,12 @@ func getOrGenerateThumbnailImage(srcBlob []byte, dstPath string) ([]byte, error)
...
@@ -509,12 +510,12 @@ func getOrGenerateThumbnailImage(srcBlob []byte, dstPath string) ([]byte, error)
return
nil
,
errors
.
Wrap
(
err
,
"failed to check thumbnail image stat"
)
return
nil
,
errors
.
Wrap
(
err
,
"failed to check thumbnail image stat"
)
}
}
if
a
vailableGeneratorAmount
<=
0
{
if
a
tomic
.
LoadInt32
(
&
availableGeneratorAmount
)
<=
0
{
return
nil
,
errors
.
New
(
"not enough available generator amount"
)
return
nil
,
errors
.
New
(
"not enough available generator amount"
)
}
}
a
vailableGeneratorAmount
--
a
tomic
.
AddInt32
(
&
availableGeneratorAmount
,
-
1
)
defer
func
()
{
defer
func
()
{
a
vailableGeneratorAmount
++
a
tomic
.
AddInt32
(
&
availableGeneratorAmount
,
1
)
}()
}()
reader
:=
bytes
.
NewReader
(
srcBlob
)
reader
:=
bytes
.
NewReader
(
srcBlob
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment