compile regex only once in filte inside regex condition

This commit is contained in:
Ben Sarmiento
2023-10-28 21:21:50 +02:00
parent 5326746f0c
commit a0a5be6bff
2 changed files with 1 additions and 60 deletions

View File

@@ -1,59 +0,0 @@
name: Build zurg-testing image
on:
push:
branches:
- main
tags:
- v0*
- latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-testing
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

View File

@@ -111,8 +111,8 @@ func (z *ZurgConfigV1) matchFilter(fileID, torrentName string, fileNames []strin
} }
} }
if filter.FileInsideRegexStr != "" { if filter.FileInsideRegexStr != "" {
for _, filename := range fileNames {
regex := compilePattern(filter.FileInsideRegexStr) regex := compilePattern(filter.FileInsideRegexStr)
for _, filename := range fileNames {
if regex.MatchString(filename) { if regex.MatchString(filename) {
return true return true
} }