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
a820fdc6
Commit
a820fdc6
authored
5 years ago
by
Christian Pointner
Browse files
Options
Downloads
Patches
Plain Diff
fix deletion of shows
parent
edfe76bb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
store/shows.go
+30
-6
30 additions, 6 deletions
store/shows.go
with
30 additions
and
6 deletions
store/shows.go
+
30
−
6
View file @
a820fdc6
...
...
@@ -178,13 +178,37 @@ func (st *Store) CloneShow(name, from string) (show *Show, err error) {
}
// this will also remove all files and playlists belonging to the show!
// TODO: fix cascading errors (deletion of files is tried before deletion of playlists
// which does not work when files are still refrenced by playlists...
func
(
st
*
Store
)
DeleteShow
(
name
string
)
error
{
if
err
:=
st
.
db
.
Delete
(
&
Show
{
Name
:
name
})
.
Error
;
err
!=
nil
{
return
err
func
(
st
*
Store
)
DeleteShow
(
name
string
)
(
err
error
)
{
tx
:=
st
.
db
.
Begin
()
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
tx
.
Rollback
()
if
err
==
nil
{
err
=
fmt
.
Errorf
(
"runtime panic: %+v"
,
r
)
}
}
}()
// We have to delete the playlists first since by default files are deleted before
// playlists which does not work as long as there are playlists that reference the files
// to be deleted.
// As soon as playlists are gone, deleting the show will cascade to delete
// the files as well.
if
err
=
tx
.
Where
(
"show_name = ?"
,
name
)
.
Delete
(
&
Playlist
{})
.
Error
;
err
!=
nil
{
tx
.
Rollback
()
return
}
if
err
=
tx
.
Delete
(
&
Show
{
Name
:
name
})
.
Error
;
err
!=
nil
{
tx
.
Rollback
()
return
}
return
os
.
RemoveAll
(
st
.
getShowPath
(
name
))
if
err
=
os
.
RemoveAll
(
st
.
getShowPath
(
name
));
err
!=
nil
{
tx
.
Rollback
()
return
}
err
=
tx
.
Commit
()
.
Error
return
}
func
(
st
*
Store
)
ListShows
()
(
shows
Shows
,
err
error
)
{
...
...
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