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">
<span class="label-body">Generate NFO files for Podcasts</span>
</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">
@ -168,7 +172,8 @@ var app = new Vue({
appendEpisodeNumberToFileName:self.appendEpisodeNumberToFileName,
darkMode:self.darkMode,
downloadEpisodeImages:self.downloadEpisodeImages,
generateNFOFile:self.generateNFOFile
generateNFOFile:self.generateNFOFile,
dontDownloadDeletedFromDisk:self.dontDownloadDeletedFromDisk
})
.then(function(response){
Vue.toasted.show('Settings saved successfully.' ,{
@ -210,7 +215,8 @@ var app = new Vue({
darkMode:{{ .setting.DarkMode }},
originalThemeSetting:{{ .setting.DarkMode }},
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"`
DownloadEpisodeImages bool `form:"downloadEpisodeImages" json:"downloadEpisodeImages" query:"downloadEpisodeImages"`
GenerateNFOFile bool `form:"generateNFOFile" json:"generateNFOFile" query:"generateNFOFile"`
DontDownloadDeletedFromDisk bool `form:"dontDownloadDeletedFromDisk" json:"dontDownloadDeletedFromDisk" query:"dontDownloadDeletedFromDisk"`
}
var searchOptions = map[string]string{

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

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

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

Loading…
Cancel
Save