mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-16 01:59:29 +02:00
Renamed ImportBackend methods to StartImport / FinishImport
This commit is contained in:
parent
14d944c7ad
commit
c13c9175e3
7 changed files with 16 additions and 16 deletions
|
@ -32,8 +32,8 @@ func (b *DumpBackend) FromConfig(config *viper.Viper) models.Backend {
|
|||
return b
|
||||
}
|
||||
|
||||
func (b *DumpBackend) Init() error { return nil }
|
||||
func (b *DumpBackend) Finish() error { return nil }
|
||||
func (b *DumpBackend) StartImport() error { return nil }
|
||||
func (b *DumpBackend) FinishImport() error { return nil }
|
||||
|
||||
func (b *DumpBackend) ImportListens(export models.ListensResult, importResult models.ImportResult, progress chan models.Progress) (models.ImportResult, error) {
|
||||
for _, listen := range export.Listens {
|
||||
|
|
|
@ -48,8 +48,8 @@ func (b *JspfBackend) FromConfig(config *viper.Viper) models.Backend {
|
|||
return b
|
||||
}
|
||||
|
||||
func (b *JspfBackend) Init() error { return nil }
|
||||
func (b *JspfBackend) Finish() error {
|
||||
func (b *JspfBackend) StartImport() error { return nil }
|
||||
func (b *JspfBackend) FinishImport() error {
|
||||
err := b.writeJspf(b.tracks)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@ func (b *ListenBrainzApiBackend) FromConfig(config *viper.Viper) models.Backend
|
|||
return b
|
||||
}
|
||||
|
||||
func (b *ListenBrainzApiBackend) Init() error { return nil }
|
||||
func (b *ListenBrainzApiBackend) Finish() error { return nil }
|
||||
func (b *ListenBrainzApiBackend) StartImport() error { return nil }
|
||||
func (b *ListenBrainzApiBackend) FinishImport() error { return nil }
|
||||
|
||||
func (b *ListenBrainzApiBackend) ExportListens(oldestTimestamp time.Time, results chan models.ListensResult, progress chan models.Progress) {
|
||||
startTime := time.Now()
|
||||
|
|
|
@ -45,8 +45,8 @@ func (b *MalojaApiBackend) FromConfig(config *viper.Viper) models.Backend {
|
|||
return b
|
||||
}
|
||||
|
||||
func (b *MalojaApiBackend) Init() error { return nil }
|
||||
func (b *MalojaApiBackend) Finish() error { return nil }
|
||||
func (b *MalojaApiBackend) StartImport() error { return nil }
|
||||
func (b *MalojaApiBackend) FinishImport() error { return nil }
|
||||
|
||||
func (b *MalojaApiBackend) ExportListens(oldestTimestamp time.Time, results chan models.ListensResult, progress chan models.Progress) {
|
||||
page := 0
|
||||
|
|
|
@ -29,7 +29,7 @@ func ProcessListensImports(importer models.ListensImport, results chan models.Li
|
|||
defer close(progress)
|
||||
result := models.ImportResult{}
|
||||
|
||||
err := importer.Init()
|
||||
err := importer.StartImport()
|
||||
if err != nil {
|
||||
handleError(result, err, out, progress)
|
||||
return
|
||||
|
@ -52,7 +52,7 @@ func ProcessListensImports(importer models.ListensImport, results chan models.Li
|
|||
progress <- models.Progress{}.FromImportResult(result)
|
||||
}
|
||||
|
||||
err = importer.Finish()
|
||||
err = importer.FinishImport()
|
||||
if err != nil {
|
||||
handleError(result, err, out, progress)
|
||||
return
|
||||
|
@ -67,7 +67,7 @@ func ProcessLovesImports(importer models.LovesImport, results chan models.LovesR
|
|||
defer close(progress)
|
||||
result := models.ImportResult{}
|
||||
|
||||
err := importer.Init()
|
||||
err := importer.StartImport()
|
||||
if err != nil {
|
||||
handleError(result, err, out, progress)
|
||||
return
|
||||
|
@ -90,7 +90,7 @@ func ProcessLovesImports(importer models.LovesImport, results chan models.LovesR
|
|||
progress <- models.Progress{}.FromImportResult(result)
|
||||
}
|
||||
|
||||
err = importer.Finish()
|
||||
err = importer.FinishImport()
|
||||
if err != nil {
|
||||
handleError(result, err, out, progress)
|
||||
return
|
||||
|
|
|
@ -43,7 +43,7 @@ func (b *ScrobblerLogBackend) FromConfig(config *viper.Viper) models.Backend {
|
|||
return b
|
||||
}
|
||||
|
||||
func (b *ScrobblerLogBackend) Init() error {
|
||||
func (b *ScrobblerLogBackend) StartImport() error {
|
||||
file, err := os.Create(b.filePath)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -64,7 +64,7 @@ func (b *ScrobblerLogBackend) Init() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (b *ScrobblerLogBackend) Finish() error {
|
||||
func (b *ScrobblerLogBackend) FinishImport() error {
|
||||
return b.file.Close()
|
||||
}
|
||||
|
||||
|
|
|
@ -39,11 +39,11 @@ type ImportBackend interface {
|
|||
|
||||
// If the backend needs to setup resources before starting to import,
|
||||
// this can be done here.
|
||||
Init() error
|
||||
StartImport() error
|
||||
|
||||
// The implementation can perform all steps here to finalize the
|
||||
// export/import and free used resources.
|
||||
Finish() error
|
||||
FinishImport() error
|
||||
}
|
||||
|
||||
// Must be implemented by services supporting the export of listens.
|
||||
|
|
Loading…
Add table
Reference in a new issue