mirror of
https://github.com/simon-ding/polaris.git
synced 2026-05-31 15:07:55 +08:00
code refactor
This commit is contained in:
@@ -3,8 +3,7 @@ package server
|
||||
import (
|
||||
"fmt"
|
||||
"polaris/db"
|
||||
"polaris/ent/media"
|
||||
storage1 "polaris/ent/storage"
|
||||
|
||||
"polaris/log"
|
||||
"polaris/pkg/storage"
|
||||
"strconv"
|
||||
@@ -113,30 +112,3 @@ func (s *Server) SuggestedMovieFolderName(c *gin.Context) (interface{}, error) {
|
||||
log.Infof("tv series of tmdb id %v suggestting name is %v", id, name)
|
||||
return gin.H{"name": name}, nil
|
||||
}
|
||||
|
||||
func (s *Server) getStorage(storageId int, mediaType media.MediaType) (storage.Storage, error) {
|
||||
st := s.db.GetStorage(storageId)
|
||||
targetPath := st.TvPath
|
||||
if mediaType == media.MediaTypeMovie {
|
||||
targetPath = st.MoviePath
|
||||
}
|
||||
|
||||
switch st.Implementation {
|
||||
case storage1.ImplementationLocal:
|
||||
|
||||
storageImpl1, err := storage.NewLocalStorage(targetPath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "new local")
|
||||
}
|
||||
return storageImpl1, nil
|
||||
|
||||
case storage1.ImplementationWebdav:
|
||||
ws := st.ToWebDavSetting()
|
||||
storageImpl1, err := storage.NewWebdavStorage(ws.URL, ws.User, ws.Password, targetPath, ws.ChangeFileHash == "true")
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "new webdav")
|
||||
}
|
||||
return storageImpl1, nil
|
||||
}
|
||||
return nil, errors.New("no storage found")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user