Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tank
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
tank
Commits
80944a01
Commit
80944a01
authored
5 years ago
by
Christian Pointner
Browse files
Options
Downloads
Patches
Plain Diff
fix error handling and rollback
parent
d661fd42
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
store/files.go
+2
-0
2 additions, 0 deletions
store/files.go
store/playlists.go
+1
-0
1 addition, 0 deletions
store/playlists.go
store/shows.go
+7
-2
7 additions, 2 deletions
store/shows.go
with
10 additions
and
2 deletions
store/files.go
+
2
−
0
View file @
80944a01
...
...
@@ -63,6 +63,7 @@ func (st *Store) UpdateFile(show string, id uint64, file File) (*File, error) {
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
tx
.
Rollback
()
// TODO: make sure to return non-nil err !!!
}
}()
if
err
:=
tx
.
Error
;
err
!=
nil
{
...
...
@@ -91,6 +92,7 @@ func (st *Store) UpdateFileMetadata(show string, id uint64, metadata map[string]
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
tx
.
Rollback
()
// TODO: make sure to return non-nil err !!!
}
}()
if
err
:=
tx
.
Error
;
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
store/playlists.go
+
1
−
0
View file @
80944a01
...
...
@@ -109,6 +109,7 @@ func (st *Store) UpdatePlaylist(show string, id uint64, playlist Playlist) (*Pla
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
tx
.
Rollback
()
// TODO: make sure to return non-nil err !!!
}
}()
if
err
:=
tx
.
Error
;
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
store/shows.go
+
7
−
2
View file @
80944a01
...
...
@@ -26,6 +26,7 @@ package store
import
(
"errors"
"fmt"
"os"
"path/filepath"
...
...
@@ -49,7 +50,7 @@ func (st *Store) createShow(tx *gorm.DB, name string) (show *Show, err error) {
}
}
show
=
&
Show
{
Name
:
name
}
err
=
st
.
db
.
FirstOrCreate
(
show
)
.
Error
err
=
tx
.
FirstOrCreate
(
show
)
.
Error
return
}
...
...
@@ -76,7 +77,7 @@ func (st *Store) cloneFiles(tx *gorm.DB, name, from string) (err error) {
}
// TODO: also clone import logs
}
return
nil
return
}
func
(
st
*
Store
)
clonePlaylists
(
tx
*
gorm
.
DB
,
name
,
from
string
)
error
{
...
...
@@ -92,6 +93,10 @@ func (st *Store) CloneShow(name, from string) (show *Show, err error) {
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
tx
.
Rollback
()
os
.
RemoveAll
(
st
.
getShowPath
(
name
))
if
err
==
nil
{
err
=
fmt
.
Errorf
(
"runtime panic: %+v"
,
r
)
}
}
}()
if
err
=
tx
.
Error
;
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment