Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autoradio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
ale
autoradio
Commits
24658d3e
Commit
24658d3e
authored
5 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Add ability to restore legacy (v2) backups
parent
157dad0a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/radioctl/radioctl.go
+65
-5
65 additions, 5 deletions
cmd/radioctl/radioctl.go
with
65 additions
and
5 deletions
cmd/radioctl/radioctl.go
+
65
−
5
View file @
24658d3e
...
...
@@ -585,8 +585,54 @@ func (c *backupCommand) Execute(ctx context.Context, f *flag.FlagSet, _ ...inter
return
subcommands
.
ExitSuccess
}
// Legacy EncodingParams type from autoradio v2.
type
legacyEncodingParams
struct
{
SourceName
string
Format
string
BitRate
int32
SampleRate
int32
Channels
int32
StereoMode
string
Quality
float32
}
// Legacy Mount type from autoradio v2.
type
legacyMount
struct
{
Name
string
Username
string
Password
string
RelayUrl
string
Fallback
string
Transcoding
*
legacyEncodingParams
}
func
(
m
*
legacyMount
)
toProto
()
*
pb
.
Mount
{
out
:=
&
pb
.
Mount
{
Path
:
m
.
Name
,
SourceUsername
:
m
.
Username
,
SourcePassword
:
m
.
Password
,
RelayUrl
:
m
.
RelayUrl
,
FallbackPath
:
m
.
Fallback
,
}
if
m
.
Transcoding
!=
nil
{
out
.
Transcode
=
true
out
.
TranscodeParams
=
&
pb
.
EncodingParams
{
SourcePath
:
m
.
Transcoding
.
SourceName
,
Format
:
m
.
Transcoding
.
Format
,
BitRate
:
m
.
Transcoding
.
BitRate
,
SampleRate
:
m
.
Transcoding
.
SampleRate
,
Channels
:
m
.
Transcoding
.
Channels
,
StereoMode
:
m
.
Transcoding
.
StereoMode
,
Quality
:
m
.
Transcoding
.
Quality
,
}
}
return
out
}
// Restore mount configuration.
type
restoreCommand
struct
{}
type
restoreCommand
struct
{
v2compat
bool
}
func
(
c
*
restoreCommand
)
Name
()
string
{
return
"restore"
}
func
(
c
*
restoreCommand
)
Synopsis
()
string
{
return
"Restore mount configuration"
}
...
...
@@ -597,7 +643,9 @@ Read a configuration dump from standard input and restore it.
`
}
func
(
c
*
restoreCommand
)
SetFlags
(
_
*
flag
.
FlagSet
)
{}
func
(
c
*
restoreCommand
)
SetFlags
(
f
*
flag
.
FlagSet
)
{
f
.
BoolVar
(
&
c
.
v2compat
,
"v2-compat"
,
false
,
"restore an autoradio v2 backup"
)
}
func
(
c
*
restoreCommand
)
Execute
(
ctx
context
.
Context
,
f
*
flag
.
FlagSet
,
_
...
interface
{})
subcommands
.
ExitStatus
{
if
f
.
NArg
()
>
0
{
...
...
@@ -605,10 +653,22 @@ func (c *restoreCommand) Execute(ctx context.Context, f *flag.FlagSet, _ ...inte
return
subcommands
.
ExitUsageError
}
decoder
:=
json
.
NewDecoder
(
os
.
Stdin
)
var
mounts
[]
*
pb
.
Mount
if
err
:=
json
.
NewDecoder
(
os
.
Stdin
)
.
Decode
(
&
mounts
);
err
!=
nil
{
log
.
Printf
(
"ERROR: %v"
,
err
)
return
subcommands
.
ExitFailure
if
c
.
v2compat
{
var
legacyMounts
[]
legacyMount
if
err
:=
decoder
.
Decode
(
&
legacyMounts
);
err
!=
nil
{
log
.
Printf
(
"ERROR: %v"
,
err
)
return
subcommands
.
ExitFailure
}
for
_
,
m
:=
range
legacyMounts
{
mounts
=
append
(
mounts
,
m
.
toProto
())
}
}
else
{
if
err
:=
decoder
.
Decode
(
&
mounts
);
err
!=
nil
{
log
.
Printf
(
"ERROR: %v"
,
err
)
return
subcommands
.
ExitFailure
}
}
client
:=
getClient
()
...
...
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