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
d661fd42
Commit
d661fd42
authored
5 years ago
by
Christian Pointner
Browse files
Options
Downloads
Patches
Plain Diff
cloning of files works now (still WIP)
parent
a7c8999c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
store/shows.go
+21
-9
21 additions, 9 deletions
store/shows.go
with
21 additions
and
9 deletions
store/shows.go
+
21
−
9
View file @
d661fd42
...
...
@@ -58,16 +58,28 @@ func (st *Store) CreateShow(name string) (show *Show, err error) {
return
st
.
createShow
(
st
.
db
,
name
)
}
func
(
st
*
Store
)
cloneFiles
(
tx
*
gorm
.
DB
,
show
string
)
error
{
// TODO:
// for file in files_of_show {
// create file in show <name> -> <dest-id>
// create hardlink for /store/base/path/<from>/<src-id> -> /store/base/path/<name>/<dest-id>
// }
func
(
st
*
Store
)
cloneFiles
(
tx
*
gorm
.
DB
,
name
,
from
string
)
(
err
error
)
{
var
files
Files
if
err
=
tx
.
Where
(
"show_name = ?"
,
from
)
.
Find
(
&
files
)
.
Error
;
err
!=
nil
{
return
}
for
_
,
file
:=
range
files
{
fromFilePath
:=
st
.
GetFilePath
(
from
,
file
.
ID
)
file
.
ID
=
0
file
.
ShowName
=
name
if
err
=
tx
.
Create
(
&
file
)
.
Error
;
err
!=
nil
{
return
}
if
err
=
os
.
Link
(
fromFilePath
,
st
.
GetFilePath
(
name
,
file
.
ID
));
err
!=
nil
{
return
}
// TODO: also clone import logs
}
return
nil
}
func
(
st
*
Store
)
clonePlaylists
(
tx
*
gorm
.
DB
,
show
string
)
error
{
func
(
st
*
Store
)
clonePlaylists
(
tx
*
gorm
.
DB
,
name
,
from
string
)
error
{
// TODO:
// for playlist in playlist_of_show {
// create file in show <name> -> <dest-id>
...
...
@@ -108,12 +120,12 @@ func (st *Store) CloneShow(name, from string) (show *Show, err error) {
tx
.
Rollback
()
return
nil
,
err
}
if
err
=
st
.
cloneFiles
(
tx
,
name
);
err
!=
nil
{
if
err
=
st
.
cloneFiles
(
tx
,
name
,
from
);
err
!=
nil
{
tx
.
Rollback
()
os
.
RemoveAll
(
st
.
getShowPath
(
name
))
return
nil
,
err
}
if
err
=
st
.
clonePlaylists
(
tx
,
name
);
err
!=
nil
{
if
err
=
st
.
clonePlaylists
(
tx
,
name
,
from
);
err
!=
nil
{
tx
.
Rollback
()
os
.
RemoveAll
(
st
.
getShowPath
(
name
))
return
nil
,
err
...
...
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