diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 224951b..20fdbdf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,6 +35,29 @@ jobs: - name: Cross-compile with xgo 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: xgo_version: latest go_version: 1.21 diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml index 8c53f47..8140d8c 100644 --- a/.github/workflows/build_docker.yml +++ b/.github/workflows/build_docker.yml @@ -56,7 +56,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - platforms: linux/amd64,linux/arm64,linux/arm/v7 + platforms: linux/amd64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/internal/torrent/repair.go b/internal/torrent/repair.go index aa6e1ee..b123120 100644 --- a/internal/torrent/repair.go +++ b/internal/torrent/repair.go @@ -38,13 +38,13 @@ func (t *TorrentManager) Repair(torrent *Torrent) { t.log.Infof("Repairing torrent %s", torrent.AccessKey) t.repair(torrent) t.log.Infof("Finished repairing torrent %s", torrent.AccessKey) - }) - var updatedPaths []string - t.assignedDirectoryCb(torrent, func(directory string) { - updatedPaths = append(updatedPaths, fmt.Sprintf("%s/%s", directory, torrent.AccessKey)) + var updatedPaths []string + t.assignedDirectoryCb(torrent, func(directory string) { + updatedPaths = append(updatedPaths, fmt.Sprintf("%s/%s", directory, torrent.AccessKey)) + }) + t.TriggerHookOnLibraryUpdate(updatedPaths) }) - t.TriggerHookOnLibraryUpdate(updatedPaths) } func (t *TorrentManager) repair(torrent *Torrent) { diff --git a/internal/universal/get.go b/internal/universal/get.go index 35d7dec..a22b4fe 100644 --- a/internal/universal/get.go +++ b/internal/universal/get.go @@ -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) unrestrict := torMgr.UnrestrictUntilOk(link) if unrestrict == nil { - // log.Warnf("File %s is no longer available, link %s", filepath.Base(file.Path), link) - file.Link = "repairing" - torMgr.Repair(torrent) + log.Warnf("File %s cannot be unrestricted (link=%s)", fileName, link) + if cfg.EnableRepair() { + 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) return } else { @@ -150,8 +154,12 @@ func (gf *GetFile) streamFileToResponse(torrent *intTor.Torrent, file *intTor.Fi if err != nil { if file != nil && unrestrict.Streamable == 1 { log.Warnf("Cannot download file %s: %v", file.Path, err) - file.Link = "repairing" - torMgr.Repair(torrent) + if cfg.EnableRepair() { + 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) 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 file != nil && unrestrict.Streamable == 1 { log.Warnf("Received a %s status code for file %s", download.Status, file.Path) - file.Link = "repairing" - torMgr.Repair(torrent) + if cfg.EnableRepair() { + 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) return