Delete if everything is unselected
This commit is contained in:
16
.github/workflows/build.yml
vendored
16
.github/workflows/build.yml
vendored
@@ -26,13 +26,18 @@ jobs:
|
||||
- name: Prepare artifacts
|
||||
run: |
|
||||
mkdir artifacts
|
||||
mv zurg-* artifacts/
|
||||
mv github.com/debridmediamanager.com/zurg/cmd/zurg-* artifacts/
|
||||
|
||||
# New step for compressing artifacts
|
||||
- name: Compress artifacts
|
||||
run: |
|
||||
tar -czvf artifacts.tar.gz -C artifacts .
|
||||
|
||||
- name: Upload artifacts to workflow
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: compiled-binaries
|
||||
path: artifacts/
|
||||
path: artifacts.tar.gz
|
||||
|
||||
release:
|
||||
needs: build
|
||||
@@ -54,12 +59,13 @@ jobs:
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
# Ensure the asset_path matches the compressed file name
|
||||
- name: Upload binaries to release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./zurg-*
|
||||
asset_name: zurg-${{ github.run_number }}-${{ github.sha }}
|
||||
asset_content_type: application/octet-stream
|
||||
asset_path: ./artifacts.tar.gz
|
||||
asset_name: zurg-${{ github.run_number }}-${{ github.sha }}.tar.gz
|
||||
asset_content_type: application/gzip
|
||||
|
||||
@@ -82,7 +82,8 @@ func handleDeleteFile(w http.ResponseWriter, segments []string, t *torrent.Torre
|
||||
return fmt.Errorf("cannot find file %s", filepath)
|
||||
}
|
||||
|
||||
file.Link = "-"
|
||||
file.Link = "unselect"
|
||||
t.SetChecksum("")
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ func Router(mux *http.ServeMux, c config.ConfigInterface, t *torrent.TorrentMana
|
||||
case "PROPFIND":
|
||||
dav.HandlePropfindRequest(w, r, t, davlog)
|
||||
|
||||
case "DELETE":
|
||||
case http.MethodDelete:
|
||||
dav.HandleDeleteRequest(w, r, t, davlog)
|
||||
|
||||
case http.MethodGet:
|
||||
|
||||
@@ -535,16 +535,24 @@ func (t *TorrentManager) repairAll() {
|
||||
return
|
||||
}
|
||||
forRepair := false
|
||||
unselected := 0
|
||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||
if file.Link == "@" || file.ForRepair {
|
||||
if file.Link == "repair" {
|
||||
t.log.Debugf("Found a file to repair for torrent %s", torrent.AccessKey)
|
||||
forRepair = true
|
||||
}
|
||||
if file.Link == "unselect" {
|
||||
unselected++
|
||||
}
|
||||
})
|
||||
if forRepair {
|
||||
t.log.Infof("Repairing %s", torrent.AccessKey)
|
||||
t.Repair(torrent.AccessKey)
|
||||
}
|
||||
if unselected == torrent.SelectedFiles.Count() && unselected > 0 {
|
||||
t.log.Infof("Deleting %s", torrent.AccessKey)
|
||||
t.Delete(torrent.AccessKey)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -756,14 +764,17 @@ func (t *TorrentManager) canCapacityHandle() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
if retryCount >= maxRetries {
|
||||
t.log.Error("Max retries reached, exiting")
|
||||
return false
|
||||
}
|
||||
delay := time.Duration(math.Pow(2, float64(retryCount))) * baseDelay
|
||||
if delay > maxDelay {
|
||||
delay = maxDelay
|
||||
}
|
||||
t.log.Infof("We have reached the max number of active torrents, waiting for %s seconds before retrying", delay)
|
||||
|
||||
if retryCount >= maxRetries {
|
||||
t.log.Error("Max retries reached, exiting")
|
||||
return false
|
||||
}
|
||||
|
||||
time.Sleep(delay)
|
||||
retryCount++
|
||||
}
|
||||
|
||||
@@ -24,8 +24,7 @@ func (t *Torrent) InProgress() bool {
|
||||
|
||||
type File struct {
|
||||
realdebrid.File
|
||||
Added string
|
||||
Link string
|
||||
ZurgFS uint64
|
||||
ForRepair bool
|
||||
Added string
|
||||
Link string
|
||||
ZurgFS uint64
|
||||
}
|
||||
|
||||
@@ -81,8 +81,7 @@ func HandleGetRequest(w http.ResponseWriter, r *http.Request, t *intTor.TorrentM
|
||||
resp := t.UnrestrictUntilOk(link)
|
||||
if resp == nil {
|
||||
log.Warnf("File %s is no longer available", file.Path)
|
||||
file.Link = "@"
|
||||
file.ForRepair = true
|
||||
file.Link = "repair"
|
||||
t.SetChecksum("") // force a recheck
|
||||
streamErrorVideo("https://www.youtube.com/watch?v=gea_FJrtFVA", w, r, t, c, log)
|
||||
} else {
|
||||
@@ -127,8 +126,7 @@ func streamFileToResponse(file *intTor.File, url string, w http.ResponseWriter,
|
||||
if err != nil {
|
||||
if file != nil {
|
||||
log.Warnf("Cannot download file %s: %v", file.Path, err)
|
||||
file.Link = "@"
|
||||
file.ForRepair = true
|
||||
file.Link = "repair"
|
||||
torMgr.SetChecksum("") // force a recheck
|
||||
}
|
||||
streamErrorVideo("https://www.youtube.com/watch?v=FSSd8cponAA", w, r, torMgr, cfg, log)
|
||||
@@ -139,8 +137,7 @@ func streamFileToResponse(file *intTor.File, url string, w http.ResponseWriter,
|
||||
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusPartialContent {
|
||||
if file != nil {
|
||||
log.Warnf("Received a %s status code for file %s", resp.Status, file.Path)
|
||||
file.Link = "@"
|
||||
file.ForRepair = true
|
||||
file.Link = "repair"
|
||||
torMgr.SetChecksum("") // force a recheck
|
||||
}
|
||||
streamErrorVideo("https://www.youtube.com/watch?v=BcseUxviVqE", w, r, torMgr, cfg, log)
|
||||
|
||||
Reference in New Issue
Block a user