Skip to content
Merged
8 changes: 5 additions & 3 deletions backup_service.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import os
import re
import git
import shutil
import requests
import zipfile
import tarfile
import logging
from datetime import datetime, timedelta
from pathlib import Path
from github import Github
# PyGithub and requests are imported inside the methods that use them, so the
# idle web process doesn't keep these heavy modules (~30 MB) in memory.
from models import db, BackupJob, RELEASE_MODES
from urllib.parse import urlparse

Expand Down Expand Up @@ -326,6 +325,7 @@ def _safe_filename(self, name):

def _download_file(self, url, destination, headers):
"""Stream a file from the GitHub API to disk"""
import requests
with requests.get(url, headers=headers, stream=True, timeout=(30, 300), allow_redirects=True) as response:
response.raise_for_status()
with open(destination, 'wb') as f:
Expand All @@ -348,6 +348,7 @@ def _download_releases(self, repository, releases_dir):
owner, repo_name = owner_repo

token = repository.github_token.strip() if repository.github_token else ''
from github import Github
g = Github(token) if token else Github()
gh_repo = g.get_repo(f"{owner}/{repo_name}")

Expand Down Expand Up @@ -520,6 +521,7 @@ def verify_github_access(self, repo_url, github_token=None):
if repo_name.endswith('.git'):
repo_name = repo_name[:-4]

from github import Github
if github_token:
g = Github(github_token)
else:
Expand Down
7 changes: 3 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
flask==3.1.3
flask-login==0.6.3
flask-wtf==1.3.0
werkzeug==3.1.8
werkzeug==3.1.9
bcrypt==5.0.0
APScheduler==3.11.3
PyGithub==2.10.0
gitpython==3.1.62
python-dotenv==1.2.3
requests==2.34.2
sqlalchemy==2.0.54
sqlalchemy==2.1.1
flask-sqlalchemy==3.1.1
wtforms==3.2.2
gunicorn==26.2.0
pytz==2026.3.post1
pytz==2026.4

Loading