Hotfix on repairs
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -37,3 +37,5 @@ error_codes.json
|
|||||||
memlog.sh
|
memlog.sh
|
||||||
stressTestAddRemove.py
|
stressTestAddRemove.py
|
||||||
*.zip
|
*.zip
|
||||||
|
|
||||||
|
pkg/anidb/
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package config
|
|||||||
import "math/rand"
|
import "math/rand"
|
||||||
|
|
||||||
type ConfigInterface interface {
|
type ConfigInterface interface {
|
||||||
|
GetConfig() ZurgConfig
|
||||||
GetVersion() string
|
GetVersion() string
|
||||||
GetToken() string
|
GetToken() string
|
||||||
GetNumOfWorkers() int
|
GetNumOfWorkers() int
|
||||||
@@ -26,24 +27,28 @@ type ConfigInterface interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ZurgConfig struct {
|
type ZurgConfig struct {
|
||||||
Version string `yaml:"zurg"`
|
Version string `yaml:"zurg" json:"-"`
|
||||||
Token string `yaml:"token"`
|
Token string `yaml:"token" json:"-"`
|
||||||
Host string `yaml:"host"`
|
Host string `yaml:"host" json:"host"`
|
||||||
Port string `yaml:"port"`
|
Port string `yaml:"port" json:"port"`
|
||||||
NumOfWorkers int `yaml:"concurrent_workers"`
|
NumOfWorkers int `yaml:"concurrent_workers" json:"concurrent_workers"`
|
||||||
RefreshEverySeconds int `yaml:"check_for_changes_every_secs"`
|
RefreshEverySeconds int `yaml:"check_for_changes_every_secs" json:"check_for_changes_every_secs"`
|
||||||
CanRepair bool `yaml:"enable_repair"`
|
CanRepair bool `yaml:"enable_repair" json:"enable_repair"`
|
||||||
OnLibraryUpdate string `yaml:"on_library_update"`
|
OnLibraryUpdate string `yaml:"on_library_update" json:"on_library_update"`
|
||||||
NetworkBufferSize int `yaml:"network_buffer_size"`
|
NetworkBufferSize int `yaml:"network_buffer_size" json:"network_buffer_size"`
|
||||||
RateLimitSleepSeconds int `yaml:"rate_limit_sleep_secs"`
|
RateLimitSleepSeconds int `yaml:"rate_limit_sleep_secs" json:"rate_limit_sleep_secs"`
|
||||||
RetainFolderNameExtension bool `yaml:"retain_folder_name_extension"`
|
RetainFolderNameExtension bool `yaml:"retain_folder_name_extension" json:"retain_folder_name_extension"`
|
||||||
RetainRDTorrentName bool `yaml:"retain_rd_torrent_name"`
|
RetainRDTorrentName bool `yaml:"retain_rd_torrent_name" json:"retain_rd_torrent_name"`
|
||||||
PreferredHosts []string `yaml:"preferred_hosts"`
|
PreferredHosts []string `yaml:"preferred_hosts" json:"preferred_hosts"`
|
||||||
ServeFromRclone bool `yaml:"serve_from_rclone"`
|
ServeFromRclone bool `yaml:"serve_from_rclone" json:"serve_from_rclone"`
|
||||||
ForceIPv6 bool `yaml:"force_ipv6"`
|
ForceIPv6 bool `yaml:"force_ipv6" json:"force_ipv6"`
|
||||||
RealDebridTimeout int `yaml:"realdebrid_timeout_secs"`
|
RealDebridTimeout int `yaml:"realdebrid_timeout_secs" json:"realdebrid_timeout_secs"`
|
||||||
RetriesUntilFailed int `yaml:"retries_until_failed"`
|
RetriesUntilFailed int `yaml:"retries_until_failed" json:"retries_until_failed"`
|
||||||
UseDownloadCache bool `yaml:"use_download_cache"`
|
UseDownloadCache bool `yaml:"use_download_cache" json:"use_download_cache"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (z *ZurgConfig) GetConfig() ZurgConfig {
|
||||||
|
return *z
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *ZurgConfig) GetToken() string {
|
func (z *ZurgConfig) GetToken() string {
|
||||||
|
|||||||
@@ -183,18 +183,19 @@ type SponsorResponse struct {
|
|||||||
Paypal string `json:"paypal"`
|
Paypal string `json:"paypal"`
|
||||||
}
|
}
|
||||||
type RootResponse struct {
|
type RootResponse struct {
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
BuiltAt string `json:"built_at"`
|
BuiltAt string `json:"built_at"`
|
||||||
GitCommit string `json:"git_commit"`
|
GitCommit string `json:"git_commit"`
|
||||||
Dav string `json:"dav"`
|
Dav string `json:"dav"`
|
||||||
Html string `json:"html"`
|
Html string `json:"html"`
|
||||||
UserInfo *realdebrid.User `json:"user_info"` // Replace UserInfoType with the actual type
|
UserInfo *realdebrid.User `json:"user_info"` // Replace UserInfoType with the actual type
|
||||||
MemAlloc uint64 `json:"mem_alloc"` // Memory allocation in MB
|
MemAlloc uint64 `json:"mem_alloc"` // Memory allocation in MB
|
||||||
TotalAlloc uint64 `json:"total_alloc"` // Total memory allocated in MB
|
TotalAlloc uint64 `json:"total_alloc"` // Total memory allocated in MB
|
||||||
Sys uint64 `json:"sys"` // System memory in MB
|
Sys uint64 `json:"sys"` // System memory in MB
|
||||||
NumGC uint32 `json:"num_gc"` // Number of completed GC cycles
|
NumGC uint32 `json:"num_gc"` // Number of completed GC cycles
|
||||||
PID int `json:"pid"` // Process ID
|
PID int `json:"pid"` // Process ID
|
||||||
Sponsor SponsorResponse `json:"sponsor_zurg"` // Sponsorship links
|
Sponsor SponsorResponse `json:"sponsor_zurg"` // Sponsorship links
|
||||||
|
Config config.ZurgConfig `json:"config"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (zr *ZurgRouter) rootHandler(resp http.ResponseWriter, req *http.Request, params httprouter.Params) {
|
func (zr *ZurgRouter) rootHandler(resp http.ResponseWriter, req *http.Request, params httprouter.Params) {
|
||||||
@@ -224,6 +225,7 @@ func (zr *ZurgRouter) rootHandler(resp http.ResponseWriter, req *http.Request, p
|
|||||||
Github: "https://github.com/sponsors/debridmediamanager",
|
Github: "https://github.com/sponsors/debridmediamanager",
|
||||||
Paypal: "https://paypal.me/yowmamasita",
|
Paypal: "https://paypal.me/yowmamasita",
|
||||||
},
|
},
|
||||||
|
Config: zr.cfg.GetConfig(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := json.NewEncoder(resp).Encode(response); err != nil {
|
if err := json.NewEncoder(resp).Encode(response); err != nil {
|
||||||
|
|||||||
@@ -581,13 +581,13 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// first solution: add the same selection, maybe it can be fixed by reinsertion?
|
// first solution: reinsert with same selection
|
||||||
if t.reinsertTorrent(torrent, "") {
|
if t.reinsertTorrent(torrent, "") {
|
||||||
t.log.Infof("Successfully downloaded torrent %s to repair it", torrent.AccessKey)
|
t.log.Infof("Successfully downloaded torrent %s to repair it", torrent.AccessKey)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// if all the selected files are missing but there are other streamable files
|
// second solution: add only the missing files
|
||||||
var missingFiles []File
|
var missingFiles []File
|
||||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||||
if !strings.HasPrefix(file.Link, "http") {
|
if !strings.HasPrefix(file.Link, "http") {
|
||||||
@@ -629,14 +629,11 @@ func (t *TorrentManager) reinsertTorrent(torrent *Torrent, missingFiles string)
|
|||||||
if missingFiles == "" {
|
if missingFiles == "" {
|
||||||
tmpSelection := ""
|
tmpSelection := ""
|
||||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||||
if !strings.HasPrefix(file.Link, "http") {
|
tmpSelection += fmt.Sprintf("%d,", file.ID) // select all files
|
||||||
tmpSelection += fmt.Sprintf("%d,", file.ID)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
if tmpSelection == "" {
|
if tmpSelection == "" {
|
||||||
return false
|
return true // nothing to repair
|
||||||
}
|
} else {
|
||||||
if len(tmpSelection) > 0 {
|
|
||||||
missingFiles = tmpSelection[:len(tmpSelection)-1]
|
missingFiles = tmpSelection[:len(tmpSelection)-1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user