Fix repairs
This commit is contained in:
23
.github/workflows/build.yml
vendored
23
.github/workflows/build.yml
vendored
@@ -35,6 +35,29 @@ jobs:
|
|||||||
|
|
||||||
- name: Cross-compile with xgo
|
- name: Cross-compile with xgo
|
||||||
uses: crazy-max/ghaction-xgo@v3
|
uses: crazy-max/ghaction-xgo@v3
|
||||||
|
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
||||||
|
with:
|
||||||
|
xgo_version: latest
|
||||||
|
go_version: 1.21
|
||||||
|
pkg: cmd/zurg
|
||||||
|
targets: linux/amd64
|
||||||
|
dest: artifacts
|
||||||
|
prefix: zurg
|
||||||
|
v: false
|
||||||
|
x: false
|
||||||
|
race: false
|
||||||
|
ldflags: >
|
||||||
|
-s -w
|
||||||
|
-X 'github.com/debridmediamanager/zurg/internal.BuiltAt=${{ steps.prep.outputs.built_at }}'
|
||||||
|
-X 'github.com/debridmediamanager/zurg/internal.GoVersion=${{ steps.prep.outputs.go_version }}'
|
||||||
|
-X 'github.com/debridmediamanager/zurg/internal.GitCommit=${{ steps.prep.outputs.git_commit }}'
|
||||||
|
-X 'github.com/debridmediamanager/zurg/internal.Version=${{ steps.version.outputs.version }}'
|
||||||
|
buildmode: default
|
||||||
|
trimpath: true
|
||||||
|
|
||||||
|
- name: Cross-compile with xgo
|
||||||
|
uses: crazy-max/ghaction-xgo@v3
|
||||||
|
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||||
with:
|
with:
|
||||||
xgo_version: latest
|
xgo_version: latest
|
||||||
go_version: 1.21
|
go_version: 1.21
|
||||||
|
|||||||
2
.github/workflows/build_docker.yml
vendored
2
.github/workflows/build_docker.yml
vendored
@@ -56,7 +56,7 @@ jobs:
|
|||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|||||||
@@ -38,13 +38,13 @@ func (t *TorrentManager) Repair(torrent *Torrent) {
|
|||||||
t.log.Infof("Repairing torrent %s", torrent.AccessKey)
|
t.log.Infof("Repairing torrent %s", torrent.AccessKey)
|
||||||
t.repair(torrent)
|
t.repair(torrent)
|
||||||
t.log.Infof("Finished repairing torrent %s", torrent.AccessKey)
|
t.log.Infof("Finished repairing torrent %s", torrent.AccessKey)
|
||||||
})
|
|
||||||
|
|
||||||
var updatedPaths []string
|
var updatedPaths []string
|
||||||
t.assignedDirectoryCb(torrent, func(directory string) {
|
t.assignedDirectoryCb(torrent, func(directory string) {
|
||||||
updatedPaths = append(updatedPaths, fmt.Sprintf("%s/%s", directory, torrent.AccessKey))
|
updatedPaths = append(updatedPaths, fmt.Sprintf("%s/%s", directory, torrent.AccessKey))
|
||||||
|
})
|
||||||
|
t.TriggerHookOnLibraryUpdate(updatedPaths)
|
||||||
})
|
})
|
||||||
t.TriggerHookOnLibraryUpdate(updatedPaths)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TorrentManager) repair(torrent *Torrent) {
|
func (t *TorrentManager) repair(torrent *Torrent) {
|
||||||
|
|||||||
@@ -68,9 +68,13 @@ func (gf *GetFile) HandleGetRequest(directory, torrentName, fileName string, res
|
|||||||
log.Debugf("Opening file %s from torrent %s (%s)", fileName, torrentName, link)
|
log.Debugf("Opening file %s from torrent %s (%s)", fileName, torrentName, link)
|
||||||
unrestrict := torMgr.UnrestrictUntilOk(link)
|
unrestrict := torMgr.UnrestrictUntilOk(link)
|
||||||
if unrestrict == nil {
|
if unrestrict == nil {
|
||||||
// log.Warnf("File %s is no longer available, link %s", filepath.Base(file.Path), link)
|
log.Warnf("File %s cannot be unrestricted (link=%s)", fileName, link)
|
||||||
file.Link = "repairing"
|
if cfg.EnableRepair() {
|
||||||
torMgr.Repair(torrent)
|
file.Link = "repairing"
|
||||||
|
torMgr.Repair(torrent)
|
||||||
|
} else {
|
||||||
|
log.Info("Repair is disabled, skipping repair for unavailable file")
|
||||||
|
}
|
||||||
http.Error(resp, "File is not available", http.StatusNotFound)
|
http.Error(resp, "File is not available", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
@@ -150,8 +154,12 @@ func (gf *GetFile) streamFileToResponse(torrent *intTor.Torrent, file *intTor.Fi
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if file != nil && unrestrict.Streamable == 1 {
|
if file != nil && unrestrict.Streamable == 1 {
|
||||||
log.Warnf("Cannot download file %s: %v", file.Path, err)
|
log.Warnf("Cannot download file %s: %v", file.Path, err)
|
||||||
file.Link = "repairing"
|
if cfg.EnableRepair() {
|
||||||
torMgr.Repair(torrent)
|
file.Link = "repairing"
|
||||||
|
torMgr.Repair(torrent)
|
||||||
|
} else {
|
||||||
|
log.Info("Repair is disabled, skipping repair for unavailable file")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
http.Error(resp, "File is not available", http.StatusNotFound)
|
http.Error(resp, "File is not available", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
@@ -161,8 +169,12 @@ func (gf *GetFile) streamFileToResponse(torrent *intTor.Torrent, file *intTor.Fi
|
|||||||
if download.StatusCode != http.StatusOK && download.StatusCode != http.StatusPartialContent {
|
if download.StatusCode != http.StatusOK && download.StatusCode != http.StatusPartialContent {
|
||||||
if file != nil && unrestrict.Streamable == 1 {
|
if file != nil && unrestrict.Streamable == 1 {
|
||||||
log.Warnf("Received a %s status code for file %s", download.Status, file.Path)
|
log.Warnf("Received a %s status code for file %s", download.Status, file.Path)
|
||||||
file.Link = "repairing"
|
if cfg.EnableRepair() {
|
||||||
torMgr.Repair(torrent)
|
file.Link = "repairing"
|
||||||
|
torMgr.Repair(torrent)
|
||||||
|
} else {
|
||||||
|
log.Info("Repair is disabled, skipping repair for unavailable file")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
http.Error(resp, "File is not available", http.StatusNotFound)
|
http.Error(resp, "File is not available", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user