setting to not redownload deleted content

pull/108/head
Akhil Gupta 3 years ago
parent daba25281a
commit 800cfaab7a

@ -93,6 +93,10 @@
<input type="checkbox" name="generateNFOFile" v-model="generateNFOFile"> <input type="checkbox" name="generateNFOFile" v-model="generateNFOFile">
<span class="label-body">Generate NFO files for Podcasts</span> <span class="label-body">Generate NFO files for Podcasts</span>
</label> </label>
<label for="dontDownloadDeletedFromDisk">
<input type="checkbox" name="dontDownloadDeletedFromDisk" v-model="dontDownloadDeletedFromDisk">
<span class="label-body">Don't re-download files deleted from disk.</span>
</label>
<input type="submit" value="Save" class="button"> <input type="submit" value="Save" class="button">
@ -168,7 +172,8 @@ var app = new Vue({
appendEpisodeNumberToFileName:self.appendEpisodeNumberToFileName, appendEpisodeNumberToFileName:self.appendEpisodeNumberToFileName,
darkMode:self.darkMode, darkMode:self.darkMode,
downloadEpisodeImages:self.downloadEpisodeImages, downloadEpisodeImages:self.downloadEpisodeImages,
generateNFOFile:self.generateNFOFile generateNFOFile:self.generateNFOFile,
dontDownloadDeletedFromDisk:self.dontDownloadDeletedFromDisk
}) })
.then(function(response){ .then(function(response){
Vue.toasted.show('Settings saved successfully.' ,{ Vue.toasted.show('Settings saved successfully.' ,{
@ -210,7 +215,8 @@ var app = new Vue({
darkMode:{{ .setting.DarkMode }}, darkMode:{{ .setting.DarkMode }},
originalThemeSetting:{{ .setting.DarkMode }}, originalThemeSetting:{{ .setting.DarkMode }},
downloadEpisodeImages:{{.setting.DownloadEpisodeImages }}, downloadEpisodeImages:{{.setting.DownloadEpisodeImages }},
generateNFOFile:{{.setting.GenerateNFOFile }}, generateNFOFile:{{ .setting.GenerateNFOFile }},
dontDownloadDeletedFromDisk:{{ .setting.DontDownloadDeletedFromDisk }},
}, },
}) })

@ -29,6 +29,7 @@ type SettingModel struct {
DarkMode bool `form:"darkMode" json:"darkMode" query:"darkMode"` DarkMode bool `form:"darkMode" json:"darkMode" query:"darkMode"`
DownloadEpisodeImages bool `form:"downloadEpisodeImages" json:"downloadEpisodeImages" query:"downloadEpisodeImages"` DownloadEpisodeImages bool `form:"downloadEpisodeImages" json:"downloadEpisodeImages" query:"downloadEpisodeImages"`
GenerateNFOFile bool `form:"generateNFOFile" json:"generateNFOFile" query:"generateNFOFile"` GenerateNFOFile bool `form:"generateNFOFile" json:"generateNFOFile" query:"generateNFOFile"`
DontDownloadDeletedFromDisk bool `form:"dontDownloadDeletedFromDisk" json:"dontDownloadDeletedFromDisk" query:"dontDownloadDeletedFromDisk"`
} }
var searchOptions = map[string]string{ var searchOptions = map[string]string{

@ -547,7 +547,7 @@ func UpdateSetting(c *gin.Context) {
err = service.UpdateSettings(model.DownloadOnAdd, model.InitialDownloadCount, err = service.UpdateSettings(model.DownloadOnAdd, model.InitialDownloadCount,
model.AutoDownload, model.AppendDateToFileName, model.AppendEpisodeNumberToFileName, model.AutoDownload, model.AppendDateToFileName, model.AppendEpisodeNumberToFileName,
model.DarkMode, model.DownloadEpisodeImages, model.GenerateNFOFile) model.DarkMode, model.DownloadEpisodeImages, model.GenerateNFOFile, model.DontDownloadDeletedFromDisk)
if err == nil { if err == nil {
c.JSON(200, gin.H{"message": "Success"}) c.JSON(200, gin.H{"message": "Success"})

@ -83,6 +83,7 @@ type Setting struct {
DarkMode bool `gorm:"default:false"` DarkMode bool `gorm:"default:false"`
DownloadEpisodeImages bool `gorm:"default:false"` DownloadEpisodeImages bool `gorm:"default:false"`
GenerateNFOFile bool `gorm:"default:false"` GenerateNFOFile bool `gorm:"default:false"`
DontDownloadDeletedFromDisk bool `gorm:"default:false"`
} }
type Migration struct { type Migration struct {
Base Base

@ -532,6 +532,7 @@ func DownloadMissingEpisodes() error {
} }
func CheckMissingFiles() error { func CheckMissingFiles() error {
data, err := db.GetAllPodcastItemsAlreadyDownloaded() data, err := db.GetAllPodcastItemsAlreadyDownloaded()
setting := db.GetOrCreateSetting()
//fmt.Println("Processing episodes: ", strconv.Itoa(len(*data))) //fmt.Println("Processing episodes: ", strconv.Itoa(len(*data)))
if err != nil { if err != nil {
@ -540,7 +541,11 @@ func CheckMissingFiles() error {
for _, item := range *data { for _, item := range *data {
fileExists := FileExists(item.DownloadPath) fileExists := FileExists(item.DownloadPath)
if !fileExists { if !fileExists {
SetPodcastItemAsNotDownloaded(item.ID, db.NotDownloaded) if setting.DontDownloadDeletedFromDisk {
SetPodcastItemAsNotDownloaded(item.ID, db.Deleted)
} else {
SetPodcastItemAsNotDownloaded(item.ID, db.NotDownloaded)
}
} }
} }
return nil return nil
@ -736,7 +741,7 @@ func GetSearchFromPodcastIndex(pod *podcastindex.Podcast) *model.CommonSearchRes
return p return p
} }
func UpdateSettings(downloadOnAdd bool, initialDownloadCount int, autoDownload bool, appendDateToFileName bool, appendEpisodeNumberToFileName bool, darkMode bool, downloadEpisodeImages bool, generateNFOFile bool) error { func UpdateSettings(downloadOnAdd bool, initialDownloadCount int, autoDownload bool, appendDateToFileName bool, appendEpisodeNumberToFileName bool, darkMode bool, downloadEpisodeImages bool, generateNFOFile bool, dontDownloadDeletedFromDisk bool) error {
setting := db.GetOrCreateSetting() setting := db.GetOrCreateSetting()
setting.AutoDownload = autoDownload setting.AutoDownload = autoDownload
@ -747,6 +752,7 @@ func UpdateSettings(downloadOnAdd bool, initialDownloadCount int, autoDownload b
setting.DarkMode = darkMode setting.DarkMode = darkMode
setting.DownloadEpisodeImages = downloadEpisodeImages setting.DownloadEpisodeImages = downloadEpisodeImages
setting.GenerateNFOFile = generateNFOFile setting.GenerateNFOFile = generateNFOFile
setting.DontDownloadDeletedFromDisk = dontDownloadDeletedFromDisk
return db.UpdateSettings(setting) return db.UpdateSettings(setting)
} }

Loading…
Cancel
Save