diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml index d2c6da0..ad34cc3 100644 --- a/.github/workflows/cleanup.yml +++ b/.github/workflows/cleanup.yml @@ -7,7 +7,7 @@ on: jobs: coronation: - runs-on: self-hosted + runs-on: thevickypedia-default permissions: actions: write steps: diff --git a/.github/workflows/markdown.yml b/.github/workflows/markdown.yml index cab9862..c1c29ae 100644 --- a/.github/workflows/markdown.yml +++ b/.github/workflows/markdown.yml @@ -2,12 +2,12 @@ name: none-shall-pass on: workflow_dispatch: - schedule: - - cron: '0 0 * * *' + push: + branches: + - main jobs: none-shall-pass: - runs-on: self-hosted + runs-on: thevickypedia-default steps: - - uses: actions/checkout@v4 - - uses: thevickypedia/none-shall-pass@v4 + - uses: thevickypedia/none-shall-pass@v5 diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index bba6ed2..757c3e0 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -6,23 +6,9 @@ on: workflow_dispatch: jobs: - deploy: - runs-on: self-hosted + pypi-publisher: + runs-on: thevickypedia-default steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build twine - - name: Create packages - run: python -m build - - name: Run twine check - run: twine check dist/* - - name: Upload to pypi - env: - TWINE_USERNAME: ${{ secrets.PYPI_USER }} - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} - run: twine upload dist/*.whl + - uses: thevickypedia/pypi-publisher@v3 + env: + token: ${{ secrets.PYPI_TOKEN }} diff --git a/pyfilebrowser/main.py b/pyfilebrowser/main.py index adfeb0b..9972b3b 100644 --- a/pyfilebrowser/main.py +++ b/pyfilebrowser/main.py @@ -47,12 +47,11 @@ def cleanup(self, log: bool = True) -> None: self.logger.info("Removed config database %s", download.executable.filebrowser_db) except FileNotFoundError as warn: self.logger.warning(warn) if log else None - if self.proxy_engine: - try: - os.remove(proxy_settings.database) - self.logger.info("Removed proxy database %s", proxy_settings.database) - except FileNotFoundError as warn: - self.logger.warning(warn) if log else None + try: + os.remove(proxy_settings.database) + self.logger.info("Removed proxy database %s", proxy_settings.database) + except FileNotFoundError as warn: + self.logger.warning(warn) if self.proxy_engine and log else None def exit_process(self) -> None: """Deletes the database file, and all the subtitles that were created by this application.""" @@ -183,6 +182,7 @@ def background_tasks(self, auth_map: Dict[str, str]) -> None: except OSError as error: self.logger.error(error) self.logger.critical("Cannot initiate proxy server") + self.cleanup() raise log_config = struct.LoggerConfig(self.logger).get() if proxy_settings.debug: diff --git a/pyfilebrowser/proxy/main.py b/pyfilebrowser/proxy/main.py index f8dc12f..599b032 100644 --- a/pyfilebrowser/proxy/main.py +++ b/pyfilebrowser/proxy/main.py @@ -138,7 +138,8 @@ async def proxy_engine(proxy_request: Request) -> Response: if proxy_request.url.path == "/api/login": if server_response.status_code == 403: await handle_auth_error(proxy_request) - else: + elif (proxy_request.client in settings.session.forbid or + settings.session.auth_counter.get(proxy_request.client.host)): LOGGER.debug("Removing %s from forbidden list", proxy_request.client.host) settings.session.forbid.discard(proxy_request.client.host) @@ -149,11 +150,14 @@ async def proxy_engine(proxy_request: Request) -> Response: LOGGER.debug("Removing %s from auth DB", proxy_request.client.host) database.remove_record(host=proxy_request.client.host) content_type = server_response.headers.get("content-type", "") - if "text/html" in content_type: + if "text" in content_type: content = server_response.text else: content = server_response.content server_response.headers.pop("content-encoding", None) + # fixme: there should be a better way to handle this + if "javascript" in content_type: # todo: not sure if this is solely because of VideoJS plugin + server_response.headers.pop("content-length", None) proxy_response = Response( content=content, status_code=server_response.status_code,