fix tests and send feature support within first api call

This commit is contained in:
2021-09-03 12:09:51 +02:00
parent 543ce5b250
commit 924f05b2d2
9 changed files with 135 additions and 74 deletions

View File

@ -67,12 +67,13 @@ func getSettingsFromDB() {
sett := settings.LoadSettings()
type InitialDataTypeResponse struct {
DarkMode bool
Pasword bool
MediacenterName string
VideoPath string
TVShowPath string
TVShowEnabled bool
DarkMode bool
Pasword bool
MediacenterName string
VideoPath string
TVShowPath string
TVShowEnabled bool
FullDeleteEnabled bool
}
regexMatchUrl := regexp.MustCompile("^http(|s)://([0-9]){1,3}\\.([0-9]){1,3}\\.([0-9]){1,3}\\.([0-9]){1,3}:[0-9]{1,5}")
@ -82,12 +83,13 @@ func getSettingsFromDB() {
serverTVShowPath := strings.TrimPrefix(sett.TVShowPath, tvshowurl)
res := InitialDataTypeResponse{
DarkMode: sett.DarkMode,
Pasword: sett.Pasword != "-1",
MediacenterName: sett.MediacenterName,
VideoPath: serverVideoPath,
TVShowPath: serverTVShowPath,
TVShowEnabled: settings.TVShowsEnabled(),
DarkMode: sett.DarkMode,
Pasword: sett.Pasword != "-1",
MediacenterName: sett.MediacenterName,
VideoPath: serverVideoPath,
TVShowPath: serverTVShowPath,
TVShowEnabled: settings.TVShowsEnabled(),
FullDeleteEnabled: settings.VideosDeletable(),
}
str, _ := json.Marshal(res)

View File

@ -420,6 +420,7 @@ func addToVideoHandlers() {
* @apiGroup video
*
* @apiParam {int} MovieId ID of video
* @apiParam {bool} FullyDelete Delete video from disk?
*
* @apiSuccess {string} result 'success' if successfully or error message if not
*/
@ -446,6 +447,7 @@ func addToVideoHandlers() {
return database.ManualSuccessResponse(err)
}
// only allow deletion of video if cli flag is set, independent of passed api arg
if settings.VideosDeletable() && args.FullyDelete {
// get physical path of video to delete
query = fmt.Sprintf("SELECT movie_url FROM videos WHERE movie_id=%d", args.MovieId)
@ -457,7 +459,8 @@ func addToVideoHandlers() {
err = os.Remove(vidpath)
if err != nil {
fmt.Printf("unable to delete file: %s\n", vidpath)
fmt.Printf("unable to delete file: %s -- %s\n", vidpath, err.Error())
return database.ManualSuccessResponse(err)
}
}