Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: "test"

# yamllint disable-line rule:truthy
on:
pull_request:
branches:
- "*"
push:
branches:
- "main"
- "master"

jobs:
test:
name: test
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- run: pip install -r release-requirements.txt
- run: pytest tests/ -v
13 changes: 2 additions & 11 deletions github_backup/github_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,12 +919,6 @@ def download_attachment_file(url, path, auth, as_app=False, fine=False):
"error": None,
}

if os.path.exists(path):
metadata["success"] = True
metadata["http_status"] = 200 # Assume success if already exists
metadata["size_bytes"] = os.path.getsize(path)
return metadata

# Create simple request (no API query params)
request = Request(url)
request.add_header("Accept", "application/octet-stream")
Expand Down Expand Up @@ -1337,10 +1331,10 @@ def download_attachments(
attachments_dir = os.path.join(item_cwd, "attachments", str(number))
manifest_path = os.path.join(attachments_dir, "manifest.json")

# Load existing manifest if skip_existing is enabled
# Load existing manifest to prevent duplicate downloads
existing_urls = set()
existing_metadata = []
if args.skip_existing and os.path.exists(manifest_path):
if os.path.exists(manifest_path):
try:
with open(manifest_path, "r") as f:
existing_manifest = json.load(f)
Expand Down Expand Up @@ -1395,9 +1389,6 @@ def download_attachments(
filename = get_attachment_filename(url)
filepath = os.path.join(attachments_dir, filename)

# Check for collision BEFORE downloading
filepath = resolve_filename_collision(filepath)

# Download and get metadata
metadata = download_attachment_file(
url,
Expand Down
6 changes: 6 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[pytest]
testpaths = tests
python_files = test_*.py
python_classes = Test*
python_functions = test_*
addopts = -v
1 change: 1 addition & 0 deletions release-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ colorama==0.4.6
docutils==0.22.3
flake8==7.3.0
gitchangelog==3.0.4
pytest==8.3.3
idna==3.11
importlib-metadata==8.7.0
jaraco.classes==3.4.0
Expand Down
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Tests for python-github-backup."""
Loading