Bug fixes
This commit is contained in:
@@ -31,9 +31,21 @@ func loadV1Config(content []byte, log *logutil.Logger) (*ZurgConfigV1, error) {
|
|||||||
configV1.Token = utils.MaskToken(configV1.Token)
|
configV1.Token = utils.MaskToken(configV1.Token)
|
||||||
bufPassword := configV1.Password
|
bufPassword := configV1.Password
|
||||||
configV1.Password = strings.Repeat("*", len(bufPassword))
|
configV1.Password = strings.Repeat("*", len(bufPassword))
|
||||||
|
|
||||||
|
// mask download tokens
|
||||||
|
bufDownloadTokens := configV1.DownloadTokens
|
||||||
|
maskedDownloadTokens := make([]string, len(configV1.DownloadTokens))
|
||||||
|
for i, token := range configV1.DownloadTokens {
|
||||||
|
maskedDownloadTokens[i] = utils.MaskToken(token)
|
||||||
|
}
|
||||||
|
configV1.DownloadTokens = maskedDownloadTokens
|
||||||
|
|
||||||
log.Debugf("Config dump: %+v", configV1)
|
log.Debugf("Config dump: %+v", configV1)
|
||||||
|
|
||||||
|
// restore original values
|
||||||
configV1.Token = bufToken
|
configV1.Token = bufToken
|
||||||
configV1.Password = bufPassword
|
configV1.Password = bufPassword
|
||||||
|
configV1.DownloadTokens = bufDownloadTokens
|
||||||
|
|
||||||
configV1.log = log
|
configV1.log = log
|
||||||
return &configV1, nil
|
return &configV1, nil
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ type RootResponse struct {
|
|||||||
Infuse string `json:"infuse"`
|
Infuse string `json:"infuse"`
|
||||||
Logs string `json:"logs"`
|
Logs string `json:"logs"`
|
||||||
UserInfo *realdebrid.User `json:"user_info"`
|
UserInfo *realdebrid.User `json:"user_info"`
|
||||||
APITrafficMB uint64 `json:"traffic_from_api"`
|
APITraffic uint64 `json:"traffic_from_api"`
|
||||||
RequestedMB uint64 `json:"requested_mb"`
|
RequestedMB uint64 `json:"requested_mb"`
|
||||||
ServedMB uint64 `json:"served_mb"`
|
ServedMB uint64 `json:"served_mb"`
|
||||||
LibrarySize int `json:"library_size"` // Number of torrents in the library
|
LibrarySize int `json:"library_size"` // Number of torrents in the library
|
||||||
@@ -102,7 +102,7 @@ func (zr *Handlers) generateResponse(resp http.ResponseWriter, req *http.Request
|
|||||||
Infuse: fmt.Sprintf("//%s/infuse/", req.Host),
|
Infuse: fmt.Sprintf("//%s/infuse/", req.Host),
|
||||||
Logs: fmt.Sprintf("//%s/logs/", req.Host),
|
Logs: fmt.Sprintf("//%s/logs/", req.Host),
|
||||||
UserInfo: userInfo,
|
UserInfo: userInfo,
|
||||||
APITrafficMB: bToMb(uint64(trafficFromAPI)),
|
APITraffic: uint64(trafficFromAPI),
|
||||||
RequestedMB: bToMb(zr.downloader.RequestedBytes.Load()),
|
RequestedMB: bToMb(zr.downloader.RequestedBytes.Load()),
|
||||||
ServedMB: bToMb(zr.downloader.TotalBytes.Load()),
|
ServedMB: bToMb(zr.downloader.TotalBytes.Load()),
|
||||||
LibrarySize: allTorrents.Count(),
|
LibrarySize: allTorrents.Count(),
|
||||||
@@ -199,10 +199,10 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
efficiency := response.ServedMB * 100 / denominator
|
efficiency := response.ServedMB * 100 / denominator
|
||||||
|
|
||||||
if zr.trafficOnStartup.Load() > response.APITrafficMB {
|
if zr.trafficOnStartup.Load() > response.APITraffic {
|
||||||
// it cannot be bigger than traffic logged
|
// it cannot be bigger than traffic logged
|
||||||
// so it must be a reset back to 0
|
// so it must be a reset back to 0
|
||||||
zr.trafficOnStartup.Store(response.APITrafficMB * 1024 * 1024)
|
zr.trafficOnStartup.Store(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
out += fmt.Sprintf(`
|
out += fmt.Sprintf(`
|
||||||
@@ -252,8 +252,8 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
|
|||||||
response.Sys,
|
response.Sys,
|
||||||
response.NumGC,
|
response.NumGC,
|
||||||
response.PID,
|
response.PID,
|
||||||
response.APITrafficMB,
|
bToMb(response.APITraffic),
|
||||||
response.APITrafficMB-bToMb(zr.trafficOnStartup.Load()),
|
bToMb(response.APITraffic-zr.trafficOnStartup.Load()),
|
||||||
response.RequestedMB,
|
response.RequestedMB,
|
||||||
response.ServedMB,
|
response.ServedMB,
|
||||||
efficiency,
|
efficiency,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func CheckFile(directory, torrentName, fileName string, w http.ResponseWriter, r
|
|||||||
}
|
}
|
||||||
|
|
||||||
file, ok := torrent.SelectedFiles.Get(fileName)
|
file, ok := torrent.SelectedFiles.Get(fileName)
|
||||||
if !ok || !file.State.Is("ok_file") {
|
if !ok || file.State.Is("deleted_file") {
|
||||||
// log.Warnf("Cannot find file %s from path %s", fileName, req.URL.Path)
|
// log.Warnf("Cannot find file %s from path %s", fileName, req.URL.Path)
|
||||||
http.Error(w, "File not found", http.StatusNotFound)
|
http.Error(w, "File not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -84,12 +84,17 @@ func (dl *Downloader) DownloadFile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
file, ok := torrent.SelectedFiles.Get(fileName)
|
file, ok := torrent.SelectedFiles.Get(fileName)
|
||||||
if !ok || !file.State.Is("ok_file") {
|
if !ok || file.State.Is("deleted_file") {
|
||||||
log.Errorf("Cannot find file %s from path %s", fileName, req.URL.Path)
|
log.Errorf("Cannot find file %s from path %s", fileName, req.URL.Path)
|
||||||
http.Error(resp, "File not found", http.StatusNotFound)
|
http.Error(resp, "File not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if file.State.Is("broken_file") {
|
||||||
|
http.Error(resp, "File is not available (being repaired)", http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
unrestrict, err := torMgr.UnrestrictFile(file)
|
unrestrict, err := torMgr.UnrestrictFile(file)
|
||||||
if utils.AreAllTokensExpired(err) {
|
if utils.AreAllTokensExpired(err) {
|
||||||
// log.Errorf("Your account has reached the bandwidth limit, please try again after 12AM CET")
|
// log.Errorf("Your account has reached the bandwidth limit, please try again after 12AM CET")
|
||||||
|
|||||||
Reference in New Issue
Block a user