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
9b8d69b2
Unverified
Commit
9b8d69b2
authored
May 09, 2023
by
boojack
Committed by
GitHub
May 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add vacuum memo relation to dev guard (#1644)
* chore: add vacuum memo relation to dev guard * chore: update
parent
84546ff1
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
14 deletions
+14
-14
activity.go
store/activity.go
+1
-1
memo.go
store/memo.go
+2
-2
resource.go
store/resource.go
+1
-1
store.go
store/store.go
+9
-9
user.go
store/user.go
+1
-1
No files found.
store/activity.go
View file @
9b8d69b2
...
...
@@ -38,7 +38,7 @@ func (raw *activityRaw) toActivity() *api.Activity {
// CreateActivity creates an instance of Activity.
func
(
s
*
Store
)
CreateActivity
(
ctx
context
.
Context
,
create
*
api
.
ActivityCreate
)
(
*
api
.
Activity
,
error
)
{
if
s
.
p
rofile
.
Mode
==
"prod"
{
if
s
.
P
rofile
.
Mode
==
"prod"
{
return
nil
,
nil
}
...
...
store/memo.go
View file @
9b8d69b2
...
...
@@ -53,7 +53,7 @@ func (s *Store) ComposeMemo(ctx context.Context, memo *api.Memo) (*api.Memo, err
if
err
:=
s
.
ComposeMemoResourceList
(
ctx
,
memo
);
err
!=
nil
{
return
nil
,
err
}
if
s
.
p
rofile
.
IsDev
()
{
if
s
.
P
rofile
.
IsDev
()
{
if
err
:=
s
.
ComposeMemoRelationList
(
ctx
,
memo
);
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -184,7 +184,7 @@ func (s *Store) DeleteMemo(ctx context.Context, delete *api.MemoDelete) error {
if
err
:=
deleteMemo
(
ctx
,
tx
,
delete
);
err
!=
nil
{
return
FormatError
(
err
)
}
if
err
:=
vacuum
(
ctx
,
tx
);
err
!=
nil
{
if
err
:=
s
.
vacuumImpl
(
ctx
,
tx
);
err
!=
nil
{
return
err
}
...
...
store/resource.go
View file @
9b8d69b2
...
...
@@ -160,7 +160,7 @@ func (s *Store) DeleteResource(ctx context.Context, delete *api.ResourceDelete)
if
err
:=
deleteResource
(
ctx
,
tx
,
delete
);
err
!=
nil
{
return
err
}
if
err
:=
vacuum
(
ctx
,
tx
);
err
!=
nil
{
if
err
:=
s
.
vacuumImpl
(
ctx
,
tx
);
err
!=
nil
{
return
err
}
...
...
store/store.go
View file @
9b8d69b2
...
...
@@ -10,9 +10,8 @@ import (
// Store provides database access to all raw objects.
type
Store
struct
{
Profile
*
profile
.
Profile
db
*
sql
.
DB
profile
*
profile
.
Profile
systemSettingCache
sync
.
Map
// map[string]*systemSettingRaw
userCache
sync
.
Map
// map[int]*userRaw
userSettingCache
sync
.
Map
// map[string]*userSettingRaw
...
...
@@ -24,8 +23,8 @@ type Store struct {
// New creates a new instance of Store.
func
New
(
db
*
sql
.
DB
,
profile
*
profile
.
Profile
)
*
Store
{
return
&
Store
{
Profile
:
profile
,
db
:
db
,
profile
:
profile
,
}
}
...
...
@@ -36,7 +35,7 @@ func (s *Store) Vacuum(ctx context.Context) error {
}
defer
tx
.
Rollback
()
if
err
:=
vacuum
(
ctx
,
tx
);
err
!=
nil
{
if
err
:=
s
.
vacuumImpl
(
ctx
,
tx
);
err
!=
nil
{
return
err
}
...
...
@@ -52,8 +51,7 @@ func (s *Store) Vacuum(ctx context.Context) error {
return
nil
}
// Exec vacuum records in a transaction.
func
vacuum
(
ctx
context
.
Context
,
tx
*
sql
.
Tx
)
error
{
func
(
s
*
Store
)
vacuumImpl
(
ctx
context
.
Context
,
tx
*
sql
.
Tx
)
error
{
if
err
:=
vacuumMemo
(
ctx
,
tx
);
err
!=
nil
{
return
err
}
...
...
@@ -72,9 +70,11 @@ func vacuum(ctx context.Context, tx *sql.Tx) error {
if
err
:=
vacuumMemoResource
(
ctx
,
tx
);
err
!=
nil
{
return
err
}
if
s
.
Profile
.
IsDev
()
{
if
err
:=
vacuumMemoRelations
(
ctx
,
tx
);
err
!=
nil
{
return
err
}
}
if
err
:=
vacuumTag
(
ctx
,
tx
);
err
!=
nil
{
// Prevent revive warning.
return
err
...
...
store/user.go
View file @
9b8d69b2
...
...
@@ -163,7 +163,7 @@ func (s *Store) DeleteUser(ctx context.Context, delete *api.UserDelete) error {
if
err
:=
deleteUser
(
ctx
,
tx
,
delete
);
err
!=
nil
{
return
err
}
if
err
:=
vacuum
(
ctx
,
tx
);
err
!=
nil
{
if
err
:=
s
.
vacuumImpl
(
ctx
,
tx
);
err
!=
nil
{
return
err
}
...
...
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