Compare commits
1 Commits
5feef51e7e
...
feature/pr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
deb329f4cf |
74
README.md
74
README.md
@@ -28,16 +28,6 @@ Orchard is a centralized binary artifact storage system that provides content-ad
|
|||||||
- **Web UI** - React-based interface for managing artifacts
|
- **Web UI** - React-based interface for managing artifacts
|
||||||
- **Docker Compose Setup** - Easy local development environment
|
- **Docker Compose Setup** - Easy local development environment
|
||||||
- **Helm Chart** - Kubernetes deployment with PostgreSQL, MinIO, and Redis subcharts
|
- **Helm Chart** - Kubernetes deployment with PostgreSQL, MinIO, and Redis subcharts
|
||||||
- **Multipart Upload** - Automatic multipart upload for files larger than 100MB
|
|
||||||
- **Resumable Uploads** - API for resumable uploads with part-by-part upload support
|
|
||||||
- **Range Requests** - HTTP range request support for partial downloads
|
|
||||||
- **Format-Specific Metadata** - Automatic extraction of metadata from package formats:
|
|
||||||
- `.deb` - Debian packages (name, version, architecture, maintainer)
|
|
||||||
- `.rpm` - RPM packages (name, version, release, architecture)
|
|
||||||
- `.tar.gz/.tgz` - Tarballs (name, version from filename)
|
|
||||||
- `.whl` - Python wheels (name, version, author)
|
|
||||||
- `.jar` - Java JARs (manifest info, Maven coordinates)
|
|
||||||
- `.zip` - ZIP files (file count, uncompressed size)
|
|
||||||
|
|
||||||
### API Endpoints
|
### API Endpoints
|
||||||
|
|
||||||
@@ -51,25 +41,12 @@ Orchard is a centralized binary artifact storage system that provides content-ad
|
|||||||
| `GET` | `/api/v1/project/:project/packages` | List packages in a project |
|
| `GET` | `/api/v1/project/:project/packages` | List packages in a project |
|
||||||
| `POST` | `/api/v1/project/:project/packages` | Create a new package |
|
| `POST` | `/api/v1/project/:project/packages` | Create a new package |
|
||||||
| `POST` | `/api/v1/project/:project/:package/upload` | Upload an artifact |
|
| `POST` | `/api/v1/project/:project/:package/upload` | Upload an artifact |
|
||||||
| `GET` | `/api/v1/project/:project/:package/+/:ref` | Download an artifact (supports Range header) |
|
| `GET` | `/api/v1/project/:project/:package/+/:ref` | Download an artifact |
|
||||||
| `HEAD` | `/api/v1/project/:project/:package/+/:ref` | Get artifact metadata without downloading |
|
|
||||||
| `GET` | `/api/v1/project/:project/:package/tags` | List all tags |
|
| `GET` | `/api/v1/project/:project/:package/tags` | List all tags |
|
||||||
| `POST` | `/api/v1/project/:project/:package/tags` | Create a tag |
|
| `POST` | `/api/v1/project/:project/:package/tags` | Create a tag |
|
||||||
| `GET` | `/api/v1/project/:project/:package/consumers` | List consumers of a package |
|
| `GET` | `/api/v1/project/:project/:package/consumers` | List consumers of a package |
|
||||||
| `GET` | `/api/v1/artifact/:id` | Get artifact metadata by hash |
|
| `GET` | `/api/v1/artifact/:id` | Get artifact metadata by hash |
|
||||||
|
|
||||||
#### Resumable Upload Endpoints
|
|
||||||
|
|
||||||
For large files, use the resumable upload API:
|
|
||||||
|
|
||||||
| Method | Endpoint | Description |
|
|
||||||
|--------|----------|-------------|
|
|
||||||
| `POST` | `/api/v1/project/:project/:package/upload/init` | Initialize resumable upload |
|
|
||||||
| `PUT` | `/api/v1/project/:project/:package/upload/:upload_id/part/:part_number` | Upload a part |
|
|
||||||
| `POST` | `/api/v1/project/:project/:package/upload/:upload_id/complete` | Complete upload |
|
|
||||||
| `DELETE` | `/api/v1/project/:project/:package/upload/:upload_id` | Abort upload |
|
|
||||||
| `GET` | `/api/v1/project/:project/:package/upload/:upload_id/status` | Get upload status |
|
|
||||||
|
|
||||||
### Reference Formats
|
### Reference Formats
|
||||||
|
|
||||||
When downloading artifacts, the `:ref` parameter supports multiple formats:
|
When downloading artifacts, the `:ref` parameter supports multiple formats:
|
||||||
@@ -169,43 +146,10 @@ Response:
|
|||||||
"size": 1048576,
|
"size": 1048576,
|
||||||
"project": "my-project",
|
"project": "my-project",
|
||||||
"package": "releases",
|
"package": "releases",
|
||||||
"tag": "v1.0.0",
|
"tag": "v1.0.0"
|
||||||
"format_metadata": {
|
|
||||||
"format": "tarball",
|
|
||||||
"package_name": "app",
|
|
||||||
"version": "1.0.0"
|
|
||||||
},
|
|
||||||
"deduplicated": false
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Resumable Upload (for large files)
|
|
||||||
|
|
||||||
For files larger than 100MB, use the resumable upload API:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 1. Initialize upload (client must compute SHA256 hash first)
|
|
||||||
curl -X POST http://localhost:8080/api/v1/project/my-project/releases/upload/init \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{
|
|
||||||
"expected_hash": "a3f5d8e12b4c67890abcdef1234567890abcdef1234567890abcdef12345678",
|
|
||||||
"filename": "large-file.tar.gz",
|
|
||||||
"size": 524288000,
|
|
||||||
"tag": "v2.0.0"
|
|
||||||
}'
|
|
||||||
|
|
||||||
# Response: {"upload_id": "abc123", "already_exists": false, "chunk_size": 10485760}
|
|
||||||
|
|
||||||
# 2. Upload parts (10MB chunks recommended)
|
|
||||||
curl -X PUT http://localhost:8080/api/v1/project/my-project/releases/upload/abc123/part/1 \
|
|
||||||
--data-binary @chunk1.bin
|
|
||||||
|
|
||||||
# 3. Complete the upload
|
|
||||||
curl -X POST http://localhost:8080/api/v1/project/my-project/releases/upload/abc123/complete \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{"tag": "v2.0.0"}'
|
|
||||||
```
|
|
||||||
|
|
||||||
### Download an Artifact
|
### Download an Artifact
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -217,12 +161,6 @@ curl -O http://localhost:8080/api/v1/project/my-project/releases/+/artifact:a3f5
|
|||||||
|
|
||||||
# Using the short URL pattern
|
# Using the short URL pattern
|
||||||
curl -O http://localhost:8080/project/my-project/releases/+/latest
|
curl -O http://localhost:8080/project/my-project/releases/+/latest
|
||||||
|
|
||||||
# Partial download (range request)
|
|
||||||
curl -H "Range: bytes=0-1023" http://localhost:8080/api/v1/project/my-project/releases/+/v1.0.0
|
|
||||||
|
|
||||||
# Check file info without downloading (HEAD request)
|
|
||||||
curl -I http://localhost:8080/api/v1/project/my-project/releases/+/v1.0.0
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Create a Tag
|
### Create a Tag
|
||||||
@@ -247,13 +185,12 @@ orchard/
|
|||||||
│ ├── app/
|
│ ├── app/
|
||||||
│ │ ├── __init__.py
|
│ │ ├── __init__.py
|
||||||
│ │ ├── config.py # Pydantic settings
|
│ │ ├── config.py # Pydantic settings
|
||||||
│ │ ├── database.py # SQLAlchemy setup and migrations
|
│ │ ├── database.py # SQLAlchemy setup
|
||||||
│ │ ├── main.py # FastAPI application
|
│ │ ├── main.py # FastAPI application
|
||||||
│ │ ├── metadata.py # Format-specific metadata extraction
|
|
||||||
│ │ ├── models.py # SQLAlchemy models
|
│ │ ├── models.py # SQLAlchemy models
|
||||||
│ │ ├── routes.py # API endpoints
|
│ │ ├── routes.py # API endpoints
|
||||||
│ │ ├── schemas.py # Pydantic schemas
|
│ │ ├── schemas.py # Pydantic schemas
|
||||||
│ │ └── storage.py # S3 storage layer with multipart support
|
│ │ └── storage.py # S3 storage layer
|
||||||
│ └── requirements.txt
|
│ └── requirements.txt
|
||||||
├── frontend/
|
├── frontend/
|
||||||
│ ├── src/
|
│ ├── src/
|
||||||
@@ -341,8 +278,9 @@ The following features are planned but not yet implemented:
|
|||||||
- [ ] Automated update propagation
|
- [ ] Automated update propagation
|
||||||
- [ ] OIDC/SAML authentication
|
- [ ] OIDC/SAML authentication
|
||||||
- [ ] API key management
|
- [ ] API key management
|
||||||
|
- [ ] Package format detection
|
||||||
|
- [ ] Multipart upload for large files
|
||||||
- [ ] Redis caching layer
|
- [ ] Redis caching layer
|
||||||
- [ ] Garbage collection for orphaned artifacts
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ from functools import lru_cache
|
|||||||
|
|
||||||
|
|
||||||
class Settings(BaseSettings):
|
class Settings(BaseSettings):
|
||||||
# Environment
|
|
||||||
env: str = "development" # "development" or "production"
|
|
||||||
|
|
||||||
# Server
|
# Server
|
||||||
server_host: str = "0.0.0.0"
|
server_host: str = "0.0.0.0"
|
||||||
server_port: int = 8080
|
server_port: int = 8080
|
||||||
@@ -31,14 +28,6 @@ class Settings(BaseSettings):
|
|||||||
sslmode = f"?sslmode={self.database_sslmode}" if self.database_sslmode else ""
|
sslmode = f"?sslmode={self.database_sslmode}" if self.database_sslmode else ""
|
||||||
return f"postgresql://{self.database_user}:{self.database_password}@{self.database_host}:{self.database_port}/{self.database_dbname}{sslmode}"
|
return f"postgresql://{self.database_user}:{self.database_password}@{self.database_host}:{self.database_port}/{self.database_dbname}{sslmode}"
|
||||||
|
|
||||||
@property
|
|
||||||
def is_development(self) -> bool:
|
|
||||||
return self.env.lower() == "development"
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_production(self) -> bool:
|
|
||||||
return self.env.lower() == "production"
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
env_prefix = "ORCHARD_"
|
env_prefix = "ORCHARD_"
|
||||||
case_sensitive = False
|
case_sensitive = False
|
||||||
|
|||||||
@@ -1,51 +1,20 @@
|
|||||||
from sqlalchemy import create_engine, text
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import sessionmaker, Session
|
from sqlalchemy.orm import sessionmaker, Session
|
||||||
from typing import Generator
|
from typing import Generator
|
||||||
import logging
|
|
||||||
|
|
||||||
from .config import get_settings
|
from .config import get_settings
|
||||||
from .models import Base
|
from .models import Base
|
||||||
|
|
||||||
settings = get_settings()
|
settings = get_settings()
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
engine = create_engine(settings.database_url, pool_pre_ping=True)
|
engine = create_engine(settings.database_url, pool_pre_ping=True)
|
||||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||||
|
|
||||||
|
|
||||||
def init_db():
|
def init_db():
|
||||||
"""Create all tables and run migrations"""
|
"""Create all tables"""
|
||||||
Base.metadata.create_all(bind=engine)
|
Base.metadata.create_all(bind=engine)
|
||||||
|
|
||||||
# Run migrations for schema updates
|
|
||||||
_run_migrations()
|
|
||||||
|
|
||||||
|
|
||||||
def _run_migrations():
|
|
||||||
"""Run manual migrations for schema updates"""
|
|
||||||
migrations = [
|
|
||||||
# Add format_metadata column to artifacts table
|
|
||||||
"""
|
|
||||||
DO $$
|
|
||||||
BEGIN
|
|
||||||
IF NOT EXISTS (
|
|
||||||
SELECT 1 FROM information_schema.columns
|
|
||||||
WHERE table_name = 'artifacts' AND column_name = 'format_metadata'
|
|
||||||
) THEN
|
|
||||||
ALTER TABLE artifacts ADD COLUMN format_metadata JSONB DEFAULT '{}';
|
|
||||||
END IF;
|
|
||||||
END $$;
|
|
||||||
""",
|
|
||||||
]
|
|
||||||
|
|
||||||
with engine.connect() as conn:
|
|
||||||
for migration in migrations:
|
|
||||||
try:
|
|
||||||
conn.execute(text(migration))
|
|
||||||
conn.commit()
|
|
||||||
except Exception as e:
|
|
||||||
logger.warning(f"Migration failed (may already be applied): {e}")
|
|
||||||
|
|
||||||
|
|
||||||
def get_db() -> Generator[Session, None, None]:
|
def get_db() -> Generator[Session, None, None]:
|
||||||
"""Dependency for getting database sessions"""
|
"""Dependency for getting database sessions"""
|
||||||
|
|||||||
@@ -2,35 +2,19 @@ from fastapi import FastAPI
|
|||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
from fastapi.responses import FileResponse
|
from fastapi.responses import FileResponse
|
||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from .config import get_settings
|
from .config import get_settings
|
||||||
from .database import init_db, SessionLocal
|
from .database import init_db
|
||||||
from .routes import router
|
from .routes import router
|
||||||
from .seed import seed_database
|
|
||||||
|
|
||||||
settings = get_settings()
|
settings = get_settings()
|
||||||
logging.basicConfig(level=logging.INFO)
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
async def lifespan(app: FastAPI):
|
async def lifespan(app: FastAPI):
|
||||||
# Startup: initialize database
|
# Startup: initialize database
|
||||||
init_db()
|
init_db()
|
||||||
|
|
||||||
# Seed test data in development mode
|
|
||||||
if settings.is_development:
|
|
||||||
logger.info(f"Running in {settings.env} mode - checking for seed data")
|
|
||||||
db = SessionLocal()
|
|
||||||
try:
|
|
||||||
seed_database(db)
|
|
||||||
finally:
|
|
||||||
db.close()
|
|
||||||
else:
|
|
||||||
logger.info(f"Running in {settings.env} mode - skipping seed data")
|
|
||||||
|
|
||||||
yield
|
yield
|
||||||
# Shutdown: cleanup if needed
|
# Shutdown: cleanup if needed
|
||||||
|
|
||||||
|
|||||||
@@ -1,354 +0,0 @@
|
|||||||
"""
|
|
||||||
Format-specific metadata extraction for uploaded artifacts.
|
|
||||||
Supports extracting version info and other metadata from package formats.
|
|
||||||
"""
|
|
||||||
import struct
|
|
||||||
import gzip
|
|
||||||
import tarfile
|
|
||||||
import io
|
|
||||||
import re
|
|
||||||
import logging
|
|
||||||
from typing import Dict, Any, Optional, BinaryIO
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def extract_metadata(file: BinaryIO, filename: str, content_type: Optional[str] = None) -> Dict[str, Any]:
|
|
||||||
"""
|
|
||||||
Extract format-specific metadata from an uploaded file.
|
|
||||||
Returns a dict with extracted metadata fields.
|
|
||||||
"""
|
|
||||||
metadata = {}
|
|
||||||
|
|
||||||
# Determine format from filename extension
|
|
||||||
lower_filename = filename.lower() if filename else ""
|
|
||||||
|
|
||||||
try:
|
|
||||||
if lower_filename.endswith(".deb"):
|
|
||||||
metadata = extract_deb_metadata(file)
|
|
||||||
elif lower_filename.endswith(".rpm"):
|
|
||||||
metadata = extract_rpm_metadata(file)
|
|
||||||
elif lower_filename.endswith(".tar.gz") or lower_filename.endswith(".tgz"):
|
|
||||||
metadata = extract_tarball_metadata(file, filename)
|
|
||||||
elif lower_filename.endswith(".whl"):
|
|
||||||
metadata = extract_wheel_metadata(file)
|
|
||||||
elif lower_filename.endswith(".jar"):
|
|
||||||
metadata = extract_jar_metadata(file)
|
|
||||||
elif lower_filename.endswith(".zip"):
|
|
||||||
metadata = extract_zip_metadata(file)
|
|
||||||
except Exception as e:
|
|
||||||
logger.warning(f"Failed to extract metadata from {filename}: {e}")
|
|
||||||
|
|
||||||
# Always seek back to start after reading
|
|
||||||
try:
|
|
||||||
file.seek(0)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return metadata
|
|
||||||
|
|
||||||
|
|
||||||
def extract_deb_metadata(file: BinaryIO) -> Dict[str, Any]:
|
|
||||||
"""
|
|
||||||
Extract metadata from a Debian .deb package.
|
|
||||||
Deb files are ar archives containing control.tar.gz with package info.
|
|
||||||
"""
|
|
||||||
metadata = {}
|
|
||||||
|
|
||||||
# Read ar archive header
|
|
||||||
ar_magic = file.read(8)
|
|
||||||
if ar_magic != b"!<arch>\n":
|
|
||||||
return metadata
|
|
||||||
|
|
||||||
# Parse ar archive to find control.tar.gz or control.tar.xz
|
|
||||||
while True:
|
|
||||||
# Read ar entry header (60 bytes)
|
|
||||||
header = file.read(60)
|
|
||||||
if len(header) < 60:
|
|
||||||
break
|
|
||||||
|
|
||||||
name = header[0:16].decode("ascii").strip()
|
|
||||||
size_str = header[48:58].decode("ascii").strip()
|
|
||||||
|
|
||||||
try:
|
|
||||||
size = int(size_str)
|
|
||||||
except ValueError:
|
|
||||||
break
|
|
||||||
|
|
||||||
if name.startswith("control.tar"):
|
|
||||||
# Read control archive
|
|
||||||
control_data = file.read(size)
|
|
||||||
|
|
||||||
# Decompress and read control file
|
|
||||||
try:
|
|
||||||
if name.endswith(".gz"):
|
|
||||||
control_data = gzip.decompress(control_data)
|
|
||||||
|
|
||||||
# Parse tar archive
|
|
||||||
with tarfile.open(fileobj=io.BytesIO(control_data), mode="r:*") as tar:
|
|
||||||
for member in tar.getmembers():
|
|
||||||
if member.name in ("./control", "control"):
|
|
||||||
f = tar.extractfile(member)
|
|
||||||
if f:
|
|
||||||
control_content = f.read().decode("utf-8", errors="replace")
|
|
||||||
metadata = parse_deb_control(control_content)
|
|
||||||
break
|
|
||||||
except Exception as e:
|
|
||||||
logger.debug(f"Failed to parse deb control: {e}")
|
|
||||||
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
# Skip to next entry (align to 2 bytes)
|
|
||||||
file.seek(size + (size % 2), 1)
|
|
||||||
|
|
||||||
return metadata
|
|
||||||
|
|
||||||
|
|
||||||
def parse_deb_control(content: str) -> Dict[str, Any]:
|
|
||||||
"""Parse Debian control file format"""
|
|
||||||
metadata = {}
|
|
||||||
current_key = None
|
|
||||||
current_value = []
|
|
||||||
|
|
||||||
for line in content.split("\n"):
|
|
||||||
if line.startswith(" ") or line.startswith("\t"):
|
|
||||||
# Continuation line
|
|
||||||
if current_key:
|
|
||||||
current_value.append(line.strip())
|
|
||||||
elif ":" in line:
|
|
||||||
# Save previous field
|
|
||||||
if current_key:
|
|
||||||
metadata[current_key] = "\n".join(current_value)
|
|
||||||
|
|
||||||
# Parse new field
|
|
||||||
key, value = line.split(":", 1)
|
|
||||||
current_key = key.strip().lower()
|
|
||||||
current_value = [value.strip()]
|
|
||||||
else:
|
|
||||||
# Empty line or malformed
|
|
||||||
if current_key:
|
|
||||||
metadata[current_key] = "\n".join(current_value)
|
|
||||||
current_key = None
|
|
||||||
current_value = []
|
|
||||||
|
|
||||||
# Don't forget the last field
|
|
||||||
if current_key:
|
|
||||||
metadata[current_key] = "\n".join(current_value)
|
|
||||||
|
|
||||||
# Extract key fields
|
|
||||||
result = {}
|
|
||||||
if "package" in metadata:
|
|
||||||
result["package_name"] = metadata["package"]
|
|
||||||
if "version" in metadata:
|
|
||||||
result["version"] = metadata["version"]
|
|
||||||
if "architecture" in metadata:
|
|
||||||
result["architecture"] = metadata["architecture"]
|
|
||||||
if "maintainer" in metadata:
|
|
||||||
result["maintainer"] = metadata["maintainer"]
|
|
||||||
if "description" in metadata:
|
|
||||||
result["description"] = metadata["description"].split("\n")[0] # First line only
|
|
||||||
if "depends" in metadata:
|
|
||||||
result["depends"] = metadata["depends"]
|
|
||||||
|
|
||||||
result["format"] = "deb"
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def extract_rpm_metadata(file: BinaryIO) -> Dict[str, Any]:
|
|
||||||
"""
|
|
||||||
Extract metadata from an RPM package.
|
|
||||||
RPM files have a lead, signature, and header with metadata.
|
|
||||||
"""
|
|
||||||
metadata = {"format": "rpm"}
|
|
||||||
|
|
||||||
# Read RPM lead (96 bytes)
|
|
||||||
lead = file.read(96)
|
|
||||||
if len(lead) < 96:
|
|
||||||
return metadata
|
|
||||||
|
|
||||||
# Check magic number
|
|
||||||
if lead[0:4] != b"\xed\xab\xee\xdb":
|
|
||||||
return metadata
|
|
||||||
|
|
||||||
# Read name from lead (offset 10, max 66 bytes)
|
|
||||||
name_bytes = lead[10:76]
|
|
||||||
null_idx = name_bytes.find(b"\x00")
|
|
||||||
if null_idx > 0:
|
|
||||||
metadata["package_name"] = name_bytes[:null_idx].decode("ascii", errors="replace")
|
|
||||||
|
|
||||||
# Skip signature header to get to the main header
|
|
||||||
# This is complex - simplified version just extracts from lead
|
|
||||||
try:
|
|
||||||
# Skip to header
|
|
||||||
while True:
|
|
||||||
header_magic = file.read(8)
|
|
||||||
if len(header_magic) < 8:
|
|
||||||
break
|
|
||||||
|
|
||||||
if header_magic[0:3] == b"\x8e\xad\xe8":
|
|
||||||
# Found header magic
|
|
||||||
# Read header index count and data size
|
|
||||||
index_count = struct.unpack(">I", header_magic[4:8])[0]
|
|
||||||
data_size_bytes = file.read(4)
|
|
||||||
if len(data_size_bytes) < 4:
|
|
||||||
break
|
|
||||||
data_size = struct.unpack(">I", data_size_bytes)[0]
|
|
||||||
|
|
||||||
# Read header entries
|
|
||||||
entries = []
|
|
||||||
for _ in range(index_count):
|
|
||||||
entry = file.read(16)
|
|
||||||
if len(entry) < 16:
|
|
||||||
break
|
|
||||||
tag, type_, offset, count = struct.unpack(">IIII", entry)
|
|
||||||
entries.append((tag, type_, offset, count))
|
|
||||||
|
|
||||||
# Read header data
|
|
||||||
header_data = file.read(data_size)
|
|
||||||
|
|
||||||
# Extract relevant tags
|
|
||||||
# Tag 1000 = Name, Tag 1001 = Version, Tag 1002 = Release
|
|
||||||
# Tag 1004 = Summary, Tag 1022 = Arch
|
|
||||||
for tag, type_, offset, count in entries:
|
|
||||||
if type_ == 6: # STRING type
|
|
||||||
end = header_data.find(b"\x00", offset)
|
|
||||||
if end > offset:
|
|
||||||
value = header_data[offset:end].decode("utf-8", errors="replace")
|
|
||||||
if tag == 1000:
|
|
||||||
metadata["package_name"] = value
|
|
||||||
elif tag == 1001:
|
|
||||||
metadata["version"] = value
|
|
||||||
elif tag == 1002:
|
|
||||||
metadata["release"] = value
|
|
||||||
elif tag == 1004:
|
|
||||||
metadata["description"] = value
|
|
||||||
elif tag == 1022:
|
|
||||||
metadata["architecture"] = value
|
|
||||||
|
|
||||||
break
|
|
||||||
except Exception as e:
|
|
||||||
logger.debug(f"Failed to parse RPM header: {e}")
|
|
||||||
|
|
||||||
return metadata
|
|
||||||
|
|
||||||
|
|
||||||
def extract_tarball_metadata(file: BinaryIO, filename: str) -> Dict[str, Any]:
|
|
||||||
"""Extract metadata from a tarball (name and version from filename)"""
|
|
||||||
metadata = {"format": "tarball"}
|
|
||||||
|
|
||||||
# Try to extract name and version from filename
|
|
||||||
# Common patterns: package-1.0.0.tar.gz, package_1.0.0.tar.gz
|
|
||||||
basename = filename
|
|
||||||
for suffix in [".tar.gz", ".tgz", ".tar.bz2", ".tar.xz"]:
|
|
||||||
if basename.lower().endswith(suffix):
|
|
||||||
basename = basename[:-len(suffix)]
|
|
||||||
break
|
|
||||||
|
|
||||||
# Try to split name and version
|
|
||||||
patterns = [
|
|
||||||
r"^(.+)-(\d+\.\d+(?:\.\d+)?(?:[-._]\w+)?)$", # name-version
|
|
||||||
r"^(.+)_(\d+\.\d+(?:\.\d+)?(?:[-._]\w+)?)$", # name_version
|
|
||||||
]
|
|
||||||
|
|
||||||
for pattern in patterns:
|
|
||||||
match = re.match(pattern, basename)
|
|
||||||
if match:
|
|
||||||
metadata["package_name"] = match.group(1)
|
|
||||||
metadata["version"] = match.group(2)
|
|
||||||
break
|
|
||||||
|
|
||||||
return metadata
|
|
||||||
|
|
||||||
|
|
||||||
def extract_wheel_metadata(file: BinaryIO) -> Dict[str, Any]:
|
|
||||||
"""Extract metadata from a Python wheel (.whl) file"""
|
|
||||||
import zipfile
|
|
||||||
|
|
||||||
metadata = {"format": "wheel"}
|
|
||||||
|
|
||||||
try:
|
|
||||||
with zipfile.ZipFile(file, "r") as zf:
|
|
||||||
# Find METADATA file in .dist-info directory
|
|
||||||
for name in zf.namelist():
|
|
||||||
if name.endswith("/METADATA") and ".dist-info/" in name:
|
|
||||||
with zf.open(name) as f:
|
|
||||||
content = f.read().decode("utf-8", errors="replace")
|
|
||||||
# Parse email-style headers
|
|
||||||
for line in content.split("\n"):
|
|
||||||
if line.startswith("Name:"):
|
|
||||||
metadata["package_name"] = line[5:].strip()
|
|
||||||
elif line.startswith("Version:"):
|
|
||||||
metadata["version"] = line[8:].strip()
|
|
||||||
elif line.startswith("Summary:"):
|
|
||||||
metadata["description"] = line[8:].strip()
|
|
||||||
elif line.startswith("Author:"):
|
|
||||||
metadata["author"] = line[7:].strip()
|
|
||||||
elif line == "":
|
|
||||||
break # End of headers
|
|
||||||
break
|
|
||||||
except Exception as e:
|
|
||||||
logger.debug(f"Failed to parse wheel: {e}")
|
|
||||||
|
|
||||||
return metadata
|
|
||||||
|
|
||||||
|
|
||||||
def extract_jar_metadata(file: BinaryIO) -> Dict[str, Any]:
|
|
||||||
"""Extract metadata from a Java JAR file"""
|
|
||||||
import zipfile
|
|
||||||
|
|
||||||
metadata = {"format": "jar"}
|
|
||||||
|
|
||||||
try:
|
|
||||||
with zipfile.ZipFile(file, "r") as zf:
|
|
||||||
# Look for MANIFEST.MF
|
|
||||||
if "META-INF/MANIFEST.MF" in zf.namelist():
|
|
||||||
with zf.open("META-INF/MANIFEST.MF") as f:
|
|
||||||
content = f.read().decode("utf-8", errors="replace")
|
|
||||||
for line in content.split("\n"):
|
|
||||||
line = line.strip()
|
|
||||||
if line.startswith("Implementation-Title:"):
|
|
||||||
metadata["package_name"] = line[21:].strip()
|
|
||||||
elif line.startswith("Implementation-Version:"):
|
|
||||||
metadata["version"] = line[23:].strip()
|
|
||||||
elif line.startswith("Bundle-Name:"):
|
|
||||||
metadata["bundle_name"] = line[12:].strip()
|
|
||||||
elif line.startswith("Bundle-Version:"):
|
|
||||||
metadata["bundle_version"] = line[15:].strip()
|
|
||||||
|
|
||||||
# Also look for pom.properties in Maven JARs
|
|
||||||
for name in zf.namelist():
|
|
||||||
if name.endswith("/pom.properties"):
|
|
||||||
with zf.open(name) as f:
|
|
||||||
content = f.read().decode("utf-8", errors="replace")
|
|
||||||
for line in content.split("\n"):
|
|
||||||
if line.startswith("artifactId="):
|
|
||||||
metadata["artifact_id"] = line[11:].strip()
|
|
||||||
elif line.startswith("groupId="):
|
|
||||||
metadata["group_id"] = line[8:].strip()
|
|
||||||
elif line.startswith("version="):
|
|
||||||
if "version" not in metadata:
|
|
||||||
metadata["version"] = line[8:].strip()
|
|
||||||
break
|
|
||||||
except Exception as e:
|
|
||||||
logger.debug(f"Failed to parse JAR: {e}")
|
|
||||||
|
|
||||||
return metadata
|
|
||||||
|
|
||||||
|
|
||||||
def extract_zip_metadata(file: BinaryIO) -> Dict[str, Any]:
|
|
||||||
"""Extract basic metadata from a ZIP file"""
|
|
||||||
import zipfile
|
|
||||||
|
|
||||||
metadata = {"format": "zip"}
|
|
||||||
|
|
||||||
try:
|
|
||||||
with zipfile.ZipFile(file, "r") as zf:
|
|
||||||
metadata["file_count"] = len(zf.namelist())
|
|
||||||
|
|
||||||
# Calculate total uncompressed size
|
|
||||||
total_size = sum(info.file_size for info in zf.infolist())
|
|
||||||
metadata["uncompressed_size"] = total_size
|
|
||||||
except Exception as e:
|
|
||||||
logger.debug(f"Failed to parse ZIP: {e}")
|
|
||||||
|
|
||||||
return metadata
|
|
||||||
@@ -64,7 +64,6 @@ class Artifact(Base):
|
|||||||
created_by = Column(String(255), nullable=False)
|
created_by = Column(String(255), nullable=False)
|
||||||
ref_count = Column(Integer, default=1)
|
ref_count = Column(Integer, default=1)
|
||||||
s3_key = Column(String(1024), nullable=False)
|
s3_key = Column(String(1024), nullable=False)
|
||||||
format_metadata = Column(JSON, default=dict) # Format-specific metadata (version, etc.)
|
|
||||||
|
|
||||||
tags = relationship("Tag", back_populates="artifact")
|
tags = relationship("Tag", back_populates="artifact")
|
||||||
uploads = relationship("Upload", back_populates="artifact")
|
uploads = relationship("Upload", back_populates="artifact")
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
from fastapi import APIRouter, Depends, HTTPException, UploadFile, File, Form, Request, Query, Header, Response
|
from fastapi import APIRouter, Depends, HTTPException, UploadFile, File, Form, Request, Query
|
||||||
from fastapi.responses import StreamingResponse
|
from fastapi.responses import StreamingResponse
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from sqlalchemy import or_, func
|
from sqlalchemy import or_, func
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
import math
|
import math
|
||||||
import re
|
import re
|
||||||
import io
|
|
||||||
import hashlib
|
|
||||||
|
|
||||||
from .database import get_db
|
from .database import get_db
|
||||||
from .storage import get_storage, S3Storage, MULTIPART_CHUNK_SIZE
|
from .storage import get_storage, S3Storage
|
||||||
from .models import Project, Package, Artifact, Tag, Upload, Consumer
|
from .models import Project, Package, Artifact, Tag, Upload, Consumer
|
||||||
from .schemas import (
|
from .schemas import (
|
||||||
ProjectCreate, ProjectResponse,
|
ProjectCreate, ProjectResponse,
|
||||||
@@ -20,14 +18,7 @@ from .schemas import (
|
|||||||
ConsumerResponse,
|
ConsumerResponse,
|
||||||
HealthResponse,
|
HealthResponse,
|
||||||
PaginatedResponse, PaginationMeta,
|
PaginatedResponse, PaginationMeta,
|
||||||
ResumableUploadInitRequest,
|
|
||||||
ResumableUploadInitResponse,
|
|
||||||
ResumableUploadPartResponse,
|
|
||||||
ResumableUploadCompleteRequest,
|
|
||||||
ResumableUploadCompleteResponse,
|
|
||||||
ResumableUploadStatusResponse,
|
|
||||||
)
|
)
|
||||||
from .metadata import extract_metadata
|
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@@ -160,7 +151,6 @@ def upload_artifact(
|
|||||||
tag: Optional[str] = Form(None),
|
tag: Optional[str] = Form(None),
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
storage: S3Storage = Depends(get_storage),
|
storage: S3Storage = Depends(get_storage),
|
||||||
content_length: Optional[int] = Header(None, alias="Content-Length"),
|
|
||||||
):
|
):
|
||||||
user_id = get_user_id(request)
|
user_id = get_user_id(request)
|
||||||
|
|
||||||
@@ -173,36 +163,13 @@ def upload_artifact(
|
|||||||
if not package:
|
if not package:
|
||||||
raise HTTPException(status_code=404, detail="Package not found")
|
raise HTTPException(status_code=404, detail="Package not found")
|
||||||
|
|
||||||
# Extract format-specific metadata before storing
|
# Store file
|
||||||
file_metadata = {}
|
sha256_hash, size, s3_key = storage.store(file.file)
|
||||||
if file.filename:
|
|
||||||
# Read file into memory for metadata extraction
|
|
||||||
file_content = file.file.read()
|
|
||||||
file.file.seek(0)
|
|
||||||
|
|
||||||
# Extract metadata
|
|
||||||
file_metadata = extract_metadata(
|
|
||||||
io.BytesIO(file_content),
|
|
||||||
file.filename,
|
|
||||||
file.content_type
|
|
||||||
)
|
|
||||||
|
|
||||||
# Store file (uses multipart for large files)
|
|
||||||
sha256_hash, size, s3_key = storage.store(file.file, content_length)
|
|
||||||
|
|
||||||
# Check if this is a deduplicated upload
|
|
||||||
deduplicated = False
|
|
||||||
|
|
||||||
# Create or update artifact record
|
# Create or update artifact record
|
||||||
artifact = db.query(Artifact).filter(Artifact.id == sha256_hash).first()
|
artifact = db.query(Artifact).filter(Artifact.id == sha256_hash).first()
|
||||||
if artifact:
|
if artifact:
|
||||||
artifact.ref_count += 1
|
artifact.ref_count += 1
|
||||||
deduplicated = True
|
|
||||||
# Merge metadata if new metadata was extracted
|
|
||||||
if file_metadata and artifact.format_metadata:
|
|
||||||
artifact.format_metadata = {**artifact.format_metadata, **file_metadata}
|
|
||||||
elif file_metadata:
|
|
||||||
artifact.format_metadata = file_metadata
|
|
||||||
else:
|
else:
|
||||||
artifact = Artifact(
|
artifact = Artifact(
|
||||||
id=sha256_hash,
|
id=sha256_hash,
|
||||||
@@ -211,7 +178,6 @@ def upload_artifact(
|
|||||||
original_name=file.filename,
|
original_name=file.filename,
|
||||||
created_by=user_id,
|
created_by=user_id,
|
||||||
s3_key=s3_key,
|
s3_key=s3_key,
|
||||||
format_metadata=file_metadata or {},
|
|
||||||
)
|
)
|
||||||
db.add(artifact)
|
db.add(artifact)
|
||||||
|
|
||||||
@@ -248,265 +214,17 @@ def upload_artifact(
|
|||||||
project=project_name,
|
project=project_name,
|
||||||
package=package_name,
|
package=package_name,
|
||||||
tag=tag,
|
tag=tag,
|
||||||
format_metadata=artifact.format_metadata,
|
|
||||||
deduplicated=deduplicated,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Resumable upload endpoints
|
# Download artifact
|
||||||
@router.post("/api/v1/project/{project_name}/{package_name}/upload/init", response_model=ResumableUploadInitResponse)
|
|
||||||
def init_resumable_upload(
|
|
||||||
project_name: str,
|
|
||||||
package_name: str,
|
|
||||||
init_request: ResumableUploadInitRequest,
|
|
||||||
request: Request,
|
|
||||||
db: Session = Depends(get_db),
|
|
||||||
storage: S3Storage = Depends(get_storage),
|
|
||||||
):
|
|
||||||
"""
|
|
||||||
Initialize a resumable upload session.
|
|
||||||
Client must provide the SHA256 hash of the file in advance.
|
|
||||||
"""
|
|
||||||
user_id = get_user_id(request)
|
|
||||||
|
|
||||||
# Validate project and package
|
|
||||||
project = db.query(Project).filter(Project.name == project_name).first()
|
|
||||||
if not project:
|
|
||||||
raise HTTPException(status_code=404, detail="Project not found")
|
|
||||||
|
|
||||||
package = db.query(Package).filter(Package.project_id == project.id, Package.name == package_name).first()
|
|
||||||
if not package:
|
|
||||||
raise HTTPException(status_code=404, detail="Package not found")
|
|
||||||
|
|
||||||
# Check if artifact already exists (deduplication)
|
|
||||||
existing_artifact = db.query(Artifact).filter(Artifact.id == init_request.expected_hash).first()
|
|
||||||
if existing_artifact:
|
|
||||||
# File already exists - increment ref count and return immediately
|
|
||||||
existing_artifact.ref_count += 1
|
|
||||||
|
|
||||||
# Record the upload
|
|
||||||
upload = Upload(
|
|
||||||
artifact_id=init_request.expected_hash,
|
|
||||||
package_id=package.id,
|
|
||||||
original_name=init_request.filename,
|
|
||||||
uploaded_by=user_id,
|
|
||||||
source_ip=request.client.host if request.client else None,
|
|
||||||
)
|
|
||||||
db.add(upload)
|
|
||||||
|
|
||||||
# Create tag if provided
|
|
||||||
if init_request.tag:
|
|
||||||
existing_tag = db.query(Tag).filter(
|
|
||||||
Tag.package_id == package.id, Tag.name == init_request.tag
|
|
||||||
).first()
|
|
||||||
if existing_tag:
|
|
||||||
existing_tag.artifact_id = init_request.expected_hash
|
|
||||||
existing_tag.created_by = user_id
|
|
||||||
else:
|
|
||||||
new_tag = Tag(
|
|
||||||
package_id=package.id,
|
|
||||||
name=init_request.tag,
|
|
||||||
artifact_id=init_request.expected_hash,
|
|
||||||
created_by=user_id,
|
|
||||||
)
|
|
||||||
db.add(new_tag)
|
|
||||||
|
|
||||||
db.commit()
|
|
||||||
|
|
||||||
return ResumableUploadInitResponse(
|
|
||||||
upload_id=None,
|
|
||||||
already_exists=True,
|
|
||||||
artifact_id=init_request.expected_hash,
|
|
||||||
chunk_size=MULTIPART_CHUNK_SIZE,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Initialize resumable upload
|
|
||||||
session = storage.initiate_resumable_upload(init_request.expected_hash)
|
|
||||||
|
|
||||||
return ResumableUploadInitResponse(
|
|
||||||
upload_id=session["upload_id"],
|
|
||||||
already_exists=False,
|
|
||||||
artifact_id=None,
|
|
||||||
chunk_size=MULTIPART_CHUNK_SIZE,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@router.put("/api/v1/project/{project_name}/{package_name}/upload/{upload_id}/part/{part_number}")
|
|
||||||
def upload_part(
|
|
||||||
project_name: str,
|
|
||||||
package_name: str,
|
|
||||||
upload_id: str,
|
|
||||||
part_number: int,
|
|
||||||
request: Request,
|
|
||||||
db: Session = Depends(get_db),
|
|
||||||
storage: S3Storage = Depends(get_storage),
|
|
||||||
):
|
|
||||||
"""
|
|
||||||
Upload a part of a resumable upload.
|
|
||||||
Part numbers start at 1.
|
|
||||||
"""
|
|
||||||
# Validate project and package exist
|
|
||||||
project = db.query(Project).filter(Project.name == project_name).first()
|
|
||||||
if not project:
|
|
||||||
raise HTTPException(status_code=404, detail="Project not found")
|
|
||||||
|
|
||||||
package = db.query(Package).filter(Package.project_id == project.id, Package.name == package_name).first()
|
|
||||||
if not package:
|
|
||||||
raise HTTPException(status_code=404, detail="Package not found")
|
|
||||||
|
|
||||||
if part_number < 1:
|
|
||||||
raise HTTPException(status_code=400, detail="Part number must be >= 1")
|
|
||||||
|
|
||||||
# Read part data from request body
|
|
||||||
import asyncio
|
|
||||||
loop = asyncio.new_event_loop()
|
|
||||||
|
|
||||||
async def read_body():
|
|
||||||
return await request.body()
|
|
||||||
|
|
||||||
try:
|
|
||||||
data = loop.run_until_complete(read_body())
|
|
||||||
finally:
|
|
||||||
loop.close()
|
|
||||||
|
|
||||||
if not data:
|
|
||||||
raise HTTPException(status_code=400, detail="No data in request body")
|
|
||||||
|
|
||||||
try:
|
|
||||||
part_info = storage.upload_part(upload_id, part_number, data)
|
|
||||||
return ResumableUploadPartResponse(
|
|
||||||
part_number=part_info["PartNumber"],
|
|
||||||
etag=part_info["ETag"],
|
|
||||||
)
|
|
||||||
except ValueError as e:
|
|
||||||
raise HTTPException(status_code=404, detail=str(e))
|
|
||||||
|
|
||||||
|
|
||||||
@router.post("/api/v1/project/{project_name}/{package_name}/upload/{upload_id}/complete")
|
|
||||||
def complete_resumable_upload(
|
|
||||||
project_name: str,
|
|
||||||
package_name: str,
|
|
||||||
upload_id: str,
|
|
||||||
complete_request: ResumableUploadCompleteRequest,
|
|
||||||
request: Request,
|
|
||||||
db: Session = Depends(get_db),
|
|
||||||
storage: S3Storage = Depends(get_storage),
|
|
||||||
):
|
|
||||||
"""Complete a resumable upload"""
|
|
||||||
user_id = get_user_id(request)
|
|
||||||
|
|
||||||
# Validate project and package
|
|
||||||
project = db.query(Project).filter(Project.name == project_name).first()
|
|
||||||
if not project:
|
|
||||||
raise HTTPException(status_code=404, detail="Project not found")
|
|
||||||
|
|
||||||
package = db.query(Package).filter(Package.project_id == project.id, Package.name == package_name).first()
|
|
||||||
if not package:
|
|
||||||
raise HTTPException(status_code=404, detail="Package not found")
|
|
||||||
|
|
||||||
try:
|
|
||||||
sha256_hash, s3_key = storage.complete_resumable_upload(upload_id)
|
|
||||||
except ValueError as e:
|
|
||||||
raise HTTPException(status_code=404, detail=str(e))
|
|
||||||
|
|
||||||
# Get file size from S3
|
|
||||||
obj_info = storage.get_object_info(s3_key)
|
|
||||||
size = obj_info["size"] if obj_info else 0
|
|
||||||
|
|
||||||
# Create artifact record
|
|
||||||
artifact = Artifact(
|
|
||||||
id=sha256_hash,
|
|
||||||
size=size,
|
|
||||||
s3_key=s3_key,
|
|
||||||
created_by=user_id,
|
|
||||||
format_metadata={},
|
|
||||||
)
|
|
||||||
db.add(artifact)
|
|
||||||
|
|
||||||
# Record upload
|
|
||||||
upload = Upload(
|
|
||||||
artifact_id=sha256_hash,
|
|
||||||
package_id=package.id,
|
|
||||||
uploaded_by=user_id,
|
|
||||||
source_ip=request.client.host if request.client else None,
|
|
||||||
)
|
|
||||||
db.add(upload)
|
|
||||||
|
|
||||||
# Create tag if provided
|
|
||||||
if complete_request.tag:
|
|
||||||
existing_tag = db.query(Tag).filter(
|
|
||||||
Tag.package_id == package.id, Tag.name == complete_request.tag
|
|
||||||
).first()
|
|
||||||
if existing_tag:
|
|
||||||
existing_tag.artifact_id = sha256_hash
|
|
||||||
existing_tag.created_by = user_id
|
|
||||||
else:
|
|
||||||
new_tag = Tag(
|
|
||||||
package_id=package.id,
|
|
||||||
name=complete_request.tag,
|
|
||||||
artifact_id=sha256_hash,
|
|
||||||
created_by=user_id,
|
|
||||||
)
|
|
||||||
db.add(new_tag)
|
|
||||||
|
|
||||||
db.commit()
|
|
||||||
|
|
||||||
return ResumableUploadCompleteResponse(
|
|
||||||
artifact_id=sha256_hash,
|
|
||||||
size=size,
|
|
||||||
project=project_name,
|
|
||||||
package=package_name,
|
|
||||||
tag=complete_request.tag,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@router.delete("/api/v1/project/{project_name}/{package_name}/upload/{upload_id}")
|
|
||||||
def abort_resumable_upload(
|
|
||||||
project_name: str,
|
|
||||||
package_name: str,
|
|
||||||
upload_id: str,
|
|
||||||
storage: S3Storage = Depends(get_storage),
|
|
||||||
):
|
|
||||||
"""Abort a resumable upload"""
|
|
||||||
try:
|
|
||||||
storage.abort_resumable_upload(upload_id)
|
|
||||||
return {"status": "aborted"}
|
|
||||||
except ValueError as e:
|
|
||||||
raise HTTPException(status_code=404, detail=str(e))
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/api/v1/project/{project_name}/{package_name}/upload/{upload_id}/status")
|
|
||||||
def get_upload_status(
|
|
||||||
project_name: str,
|
|
||||||
package_name: str,
|
|
||||||
upload_id: str,
|
|
||||||
storage: S3Storage = Depends(get_storage),
|
|
||||||
):
|
|
||||||
"""Get status of a resumable upload"""
|
|
||||||
try:
|
|
||||||
parts = storage.list_upload_parts(upload_id)
|
|
||||||
uploaded_parts = [p["PartNumber"] for p in parts]
|
|
||||||
total_bytes = sum(p.get("Size", 0) for p in parts)
|
|
||||||
|
|
||||||
return ResumableUploadStatusResponse(
|
|
||||||
upload_id=upload_id,
|
|
||||||
uploaded_parts=uploaded_parts,
|
|
||||||
total_uploaded_bytes=total_bytes,
|
|
||||||
)
|
|
||||||
except ValueError as e:
|
|
||||||
raise HTTPException(status_code=404, detail=str(e))
|
|
||||||
|
|
||||||
|
|
||||||
# Download artifact with range request support
|
|
||||||
@router.get("/api/v1/project/{project_name}/{package_name}/+/{ref}")
|
@router.get("/api/v1/project/{project_name}/{package_name}/+/{ref}")
|
||||||
def download_artifact(
|
def download_artifact(
|
||||||
project_name: str,
|
project_name: str,
|
||||||
package_name: str,
|
package_name: str,
|
||||||
ref: str,
|
ref: str,
|
||||||
request: Request,
|
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
storage: S3Storage = Depends(get_storage),
|
storage: S3Storage = Depends(get_storage),
|
||||||
range: Optional[str] = Header(None),
|
|
||||||
):
|
):
|
||||||
# Get project and package
|
# Get project and package
|
||||||
project = db.query(Project).filter(Project.name == project_name).first()
|
project = db.query(Project).filter(Project.name == project_name).first()
|
||||||
@@ -541,90 +259,15 @@ def download_artifact(
|
|||||||
if not artifact:
|
if not artifact:
|
||||||
raise HTTPException(status_code=404, detail="Artifact not found")
|
raise HTTPException(status_code=404, detail="Artifact not found")
|
||||||
|
|
||||||
|
# Stream from S3
|
||||||
|
stream = storage.get_stream(artifact.s3_key)
|
||||||
|
|
||||||
filename = artifact.original_name or f"{artifact.id}"
|
filename = artifact.original_name or f"{artifact.id}"
|
||||||
|
|
||||||
# Handle range requests
|
|
||||||
if range:
|
|
||||||
stream, content_length, content_range = storage.get_stream(artifact.s3_key, range)
|
|
||||||
|
|
||||||
headers = {
|
|
||||||
"Content-Disposition": f'attachment; filename="{filename}"',
|
|
||||||
"Accept-Ranges": "bytes",
|
|
||||||
"Content-Length": str(content_length),
|
|
||||||
}
|
|
||||||
if content_range:
|
|
||||||
headers["Content-Range"] = content_range
|
|
||||||
|
|
||||||
return StreamingResponse(
|
|
||||||
stream,
|
|
||||||
status_code=206, # Partial Content
|
|
||||||
media_type=artifact.content_type or "application/octet-stream",
|
|
||||||
headers=headers,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Full download
|
|
||||||
stream, content_length, _ = storage.get_stream(artifact.s3_key)
|
|
||||||
|
|
||||||
return StreamingResponse(
|
return StreamingResponse(
|
||||||
stream,
|
stream,
|
||||||
media_type=artifact.content_type or "application/octet-stream",
|
media_type=artifact.content_type or "application/octet-stream",
|
||||||
headers={
|
headers={"Content-Disposition": f'attachment; filename="{filename}"'},
|
||||||
"Content-Disposition": f'attachment; filename="{filename}"',
|
|
||||||
"Accept-Ranges": "bytes",
|
|
||||||
"Content-Length": str(content_length),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# HEAD request for download (to check file info without downloading)
|
|
||||||
@router.head("/api/v1/project/{project_name}/{package_name}/+/{ref}")
|
|
||||||
def head_artifact(
|
|
||||||
project_name: str,
|
|
||||||
package_name: str,
|
|
||||||
ref: str,
|
|
||||||
db: Session = Depends(get_db),
|
|
||||||
storage: S3Storage = Depends(get_storage),
|
|
||||||
):
|
|
||||||
# Get project and package
|
|
||||||
project = db.query(Project).filter(Project.name == project_name).first()
|
|
||||||
if not project:
|
|
||||||
raise HTTPException(status_code=404, detail="Project not found")
|
|
||||||
|
|
||||||
package = db.query(Package).filter(Package.project_id == project.id, Package.name == package_name).first()
|
|
||||||
if not package:
|
|
||||||
raise HTTPException(status_code=404, detail="Package not found")
|
|
||||||
|
|
||||||
# Resolve reference to artifact (same logic as download)
|
|
||||||
artifact = None
|
|
||||||
if ref.startswith("artifact:"):
|
|
||||||
artifact_id = ref[9:]
|
|
||||||
artifact = db.query(Artifact).filter(Artifact.id == artifact_id).first()
|
|
||||||
elif ref.startswith("tag:") or ref.startswith("version:"):
|
|
||||||
tag_name = ref.split(":", 1)[1]
|
|
||||||
tag = db.query(Tag).filter(Tag.package_id == package.id, Tag.name == tag_name).first()
|
|
||||||
if tag:
|
|
||||||
artifact = db.query(Artifact).filter(Artifact.id == tag.artifact_id).first()
|
|
||||||
else:
|
|
||||||
tag = db.query(Tag).filter(Tag.package_id == package.id, Tag.name == ref).first()
|
|
||||||
if tag:
|
|
||||||
artifact = db.query(Artifact).filter(Artifact.id == tag.artifact_id).first()
|
|
||||||
else:
|
|
||||||
artifact = db.query(Artifact).filter(Artifact.id == ref).first()
|
|
||||||
|
|
||||||
if not artifact:
|
|
||||||
raise HTTPException(status_code=404, detail="Artifact not found")
|
|
||||||
|
|
||||||
filename = artifact.original_name or f"{artifact.id}"
|
|
||||||
|
|
||||||
return Response(
|
|
||||||
content=b"",
|
|
||||||
media_type=artifact.content_type or "application/octet-stream",
|
|
||||||
headers={
|
|
||||||
"Content-Disposition": f'attachment; filename="{filename}"',
|
|
||||||
"Accept-Ranges": "bytes",
|
|
||||||
"Content-Length": str(artifact.size),
|
|
||||||
"X-Artifact-Id": artifact.id,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -634,12 +277,10 @@ def download_artifact_compat(
|
|||||||
project_name: str,
|
project_name: str,
|
||||||
package_name: str,
|
package_name: str,
|
||||||
ref: str,
|
ref: str,
|
||||||
request: Request,
|
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
storage: S3Storage = Depends(get_storage),
|
storage: S3Storage = Depends(get_storage),
|
||||||
range: Optional[str] = Header(None),
|
|
||||||
):
|
):
|
||||||
return download_artifact(project_name, package_name, ref, request, db, storage, range)
|
return download_artifact(project_name, package_name, ref, db, storage)
|
||||||
|
|
||||||
|
|
||||||
# Tag routes
|
# Tag routes
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Optional, List, Dict, Any, Generic, TypeVar
|
from typing import Optional, List, Generic, TypeVar
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
@@ -66,7 +66,6 @@ class ArtifactResponse(BaseModel):
|
|||||||
created_at: datetime
|
created_at: datetime
|
||||||
created_by: str
|
created_by: str
|
||||||
ref_count: int
|
ref_count: int
|
||||||
format_metadata: Optional[Dict[str, Any]] = None
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
from_attributes = True
|
from_attributes = True
|
||||||
@@ -97,53 +96,6 @@ class UploadResponse(BaseModel):
|
|||||||
project: str
|
project: str
|
||||||
package: str
|
package: str
|
||||||
tag: Optional[str]
|
tag: Optional[str]
|
||||||
format_metadata: Optional[Dict[str, Any]] = None
|
|
||||||
deduplicated: bool = False
|
|
||||||
|
|
||||||
|
|
||||||
# Resumable upload schemas
|
|
||||||
class ResumableUploadInitRequest(BaseModel):
|
|
||||||
"""Request to initiate a resumable upload"""
|
|
||||||
expected_hash: str # SHA256 hash of the file (client must compute)
|
|
||||||
filename: str
|
|
||||||
content_type: Optional[str] = None
|
|
||||||
size: int
|
|
||||||
tag: Optional[str] = None
|
|
||||||
|
|
||||||
|
|
||||||
class ResumableUploadInitResponse(BaseModel):
|
|
||||||
"""Response from initiating a resumable upload"""
|
|
||||||
upload_id: Optional[str] # None if file already exists
|
|
||||||
already_exists: bool
|
|
||||||
artifact_id: Optional[str] = None # Set if already_exists is True
|
|
||||||
chunk_size: int # Recommended chunk size for parts
|
|
||||||
|
|
||||||
|
|
||||||
class ResumableUploadPartResponse(BaseModel):
|
|
||||||
"""Response from uploading a part"""
|
|
||||||
part_number: int
|
|
||||||
etag: str
|
|
||||||
|
|
||||||
|
|
||||||
class ResumableUploadCompleteRequest(BaseModel):
|
|
||||||
"""Request to complete a resumable upload"""
|
|
||||||
tag: Optional[str] = None
|
|
||||||
|
|
||||||
|
|
||||||
class ResumableUploadCompleteResponse(BaseModel):
|
|
||||||
"""Response from completing a resumable upload"""
|
|
||||||
artifact_id: str
|
|
||||||
size: int
|
|
||||||
project: str
|
|
||||||
package: str
|
|
||||||
tag: Optional[str]
|
|
||||||
|
|
||||||
|
|
||||||
class ResumableUploadStatusResponse(BaseModel):
|
|
||||||
"""Status of a resumable upload"""
|
|
||||||
upload_id: str
|
|
||||||
uploaded_parts: List[int]
|
|
||||||
total_uploaded_bytes: int
|
|
||||||
|
|
||||||
|
|
||||||
# Consumer schemas
|
# Consumer schemas
|
||||||
|
|||||||
@@ -1,222 +0,0 @@
|
|||||||
"""
|
|
||||||
Test data seeding for development environment.
|
|
||||||
"""
|
|
||||||
import hashlib
|
|
||||||
import logging
|
|
||||||
from sqlalchemy.orm import Session
|
|
||||||
|
|
||||||
from .models import Project, Package, Artifact, Tag, Upload
|
|
||||||
from .storage import get_storage
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
# Test data definitions
|
|
||||||
TEST_PROJECTS = [
|
|
||||||
{
|
|
||||||
"name": "frontend-libs",
|
|
||||||
"description": "Shared frontend libraries and components",
|
|
||||||
"is_public": True,
|
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "ui-components",
|
|
||||||
"description": "Reusable UI component library",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "design-tokens",
|
|
||||||
"description": "Design system tokens and variables",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "backend-services",
|
|
||||||
"description": "Backend microservices and shared utilities",
|
|
||||||
"is_public": True,
|
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "auth-lib",
|
|
||||||
"description": "Authentication and authorization library",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "common-utils",
|
|
||||||
"description": "Common utility functions",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "api-client",
|
|
||||||
"description": "Generated API client library",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "mobile-apps",
|
|
||||||
"description": "Mobile application builds and assets",
|
|
||||||
"is_public": True,
|
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "ios-release",
|
|
||||||
"description": "iOS release builds",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "android-release",
|
|
||||||
"description": "Android release builds",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "internal-tools",
|
|
||||||
"description": "Internal development tools (private)",
|
|
||||||
"is_public": False,
|
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "dev-scripts",
|
|
||||||
"description": "Development automation scripts",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
# Sample artifacts to create (content, tags)
|
|
||||||
TEST_ARTIFACTS = [
|
|
||||||
{
|
|
||||||
"project": "frontend-libs",
|
|
||||||
"package": "ui-components",
|
|
||||||
"content": b"/* UI Components v1.0.0 */\nexport const Button = () => {};\nexport const Input = () => {};\n",
|
|
||||||
"filename": "ui-components-1.0.0.js",
|
|
||||||
"content_type": "application/javascript",
|
|
||||||
"tags": ["v1.0.0", "latest"],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"project": "frontend-libs",
|
|
||||||
"package": "ui-components",
|
|
||||||
"content": b"/* UI Components v1.1.0 */\nexport const Button = () => {};\nexport const Input = () => {};\nexport const Modal = () => {};\n",
|
|
||||||
"filename": "ui-components-1.1.0.js",
|
|
||||||
"content_type": "application/javascript",
|
|
||||||
"tags": ["v1.1.0"],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"project": "frontend-libs",
|
|
||||||
"package": "design-tokens",
|
|
||||||
"content": b'{"colors": {"primary": "#007bff", "secondary": "#6c757d"}, "spacing": {"sm": "8px", "md": "16px"}}',
|
|
||||||
"filename": "tokens.json",
|
|
||||||
"content_type": "application/json",
|
|
||||||
"tags": ["v1.0.0", "latest"],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"project": "backend-services",
|
|
||||||
"package": "common-utils",
|
|
||||||
"content": b"# Common Utils\n\ndef format_date(dt):\n return dt.isoformat()\n\ndef slugify(text):\n return text.lower().replace(' ', '-')\n",
|
|
||||||
"filename": "utils-2.0.0.py",
|
|
||||||
"content_type": "text/x-python",
|
|
||||||
"tags": ["v2.0.0", "stable", "latest"],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"project": "backend-services",
|
|
||||||
"package": "auth-lib",
|
|
||||||
"content": b"package auth\n\nfunc ValidateToken(token string) bool {\n return len(token) > 0\n}\n",
|
|
||||||
"filename": "auth-lib-1.0.0.go",
|
|
||||||
"content_type": "text/x-go",
|
|
||||||
"tags": ["v1.0.0", "latest"],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def is_database_empty(db: Session) -> bool:
|
|
||||||
"""Check if the database has any projects."""
|
|
||||||
return db.query(Project).first() is None
|
|
||||||
|
|
||||||
|
|
||||||
def seed_database(db: Session) -> None:
|
|
||||||
"""Seed the database with test data."""
|
|
||||||
if not is_database_empty(db):
|
|
||||||
logger.info("Database already has data, skipping seed")
|
|
||||||
return
|
|
||||||
|
|
||||||
logger.info("Seeding database with test data...")
|
|
||||||
storage = get_storage()
|
|
||||||
|
|
||||||
# Create projects and packages
|
|
||||||
project_map = {}
|
|
||||||
package_map = {}
|
|
||||||
|
|
||||||
for project_data in TEST_PROJECTS:
|
|
||||||
project = Project(
|
|
||||||
name=project_data["name"],
|
|
||||||
description=project_data["description"],
|
|
||||||
is_public=project_data["is_public"],
|
|
||||||
created_by="seed-user",
|
|
||||||
)
|
|
||||||
db.add(project)
|
|
||||||
db.flush() # Get the ID
|
|
||||||
project_map[project_data["name"]] = project
|
|
||||||
|
|
||||||
for package_data in project_data["packages"]:
|
|
||||||
package = Package(
|
|
||||||
project_id=project.id,
|
|
||||||
name=package_data["name"],
|
|
||||||
description=package_data["description"],
|
|
||||||
)
|
|
||||||
db.add(package)
|
|
||||||
db.flush()
|
|
||||||
package_map[(project_data["name"], package_data["name"])] = package
|
|
||||||
|
|
||||||
logger.info(f"Created {len(project_map)} projects and {len(package_map)} packages")
|
|
||||||
|
|
||||||
# Create artifacts and tags
|
|
||||||
artifact_count = 0
|
|
||||||
tag_count = 0
|
|
||||||
|
|
||||||
for artifact_data in TEST_ARTIFACTS:
|
|
||||||
project = project_map[artifact_data["project"]]
|
|
||||||
package = package_map[(artifact_data["project"], artifact_data["package"])]
|
|
||||||
|
|
||||||
content = artifact_data["content"]
|
|
||||||
sha256_hash = hashlib.sha256(content).hexdigest()
|
|
||||||
size = len(content)
|
|
||||||
s3_key = f"fruits/{sha256_hash[:2]}/{sha256_hash[2:4]}/{sha256_hash}"
|
|
||||||
|
|
||||||
# Store in S3
|
|
||||||
try:
|
|
||||||
storage.client.put_object(
|
|
||||||
Bucket=storage.bucket,
|
|
||||||
Key=s3_key,
|
|
||||||
Body=content,
|
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
logger.warning(f"Failed to store artifact in S3: {e}")
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Create artifact record
|
|
||||||
artifact = Artifact(
|
|
||||||
id=sha256_hash,
|
|
||||||
size=size,
|
|
||||||
content_type=artifact_data["content_type"],
|
|
||||||
original_name=artifact_data["filename"],
|
|
||||||
created_by="seed-user",
|
|
||||||
s3_key=s3_key,
|
|
||||||
ref_count=len(artifact_data["tags"]),
|
|
||||||
)
|
|
||||||
db.add(artifact)
|
|
||||||
|
|
||||||
# Create upload record
|
|
||||||
upload = Upload(
|
|
||||||
artifact_id=sha256_hash,
|
|
||||||
package_id=package.id,
|
|
||||||
original_name=artifact_data["filename"],
|
|
||||||
uploaded_by="seed-user",
|
|
||||||
)
|
|
||||||
db.add(upload)
|
|
||||||
artifact_count += 1
|
|
||||||
|
|
||||||
# Create tags
|
|
||||||
for tag_name in artifact_data["tags"]:
|
|
||||||
tag = Tag(
|
|
||||||
package_id=package.id,
|
|
||||||
name=tag_name,
|
|
||||||
artifact_id=sha256_hash,
|
|
||||||
created_by="seed-user",
|
|
||||||
)
|
|
||||||
db.add(tag)
|
|
||||||
tag_count += 1
|
|
||||||
|
|
||||||
db.commit()
|
|
||||||
logger.info(f"Created {artifact_count} artifacts and {tag_count} tags")
|
|
||||||
logger.info("Database seeding complete")
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
from typing import BinaryIO, Tuple
|
||||||
from typing import BinaryIO, Tuple, Optional, Dict, Any, Generator
|
|
||||||
import boto3
|
import boto3
|
||||||
from botocore.config import Config
|
from botocore.config import Config
|
||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
@@ -8,14 +7,6 @@ from botocore.exceptions import ClientError
|
|||||||
from .config import get_settings
|
from .config import get_settings
|
||||||
|
|
||||||
settings = get_settings()
|
settings = get_settings()
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
# Threshold for multipart upload (100MB)
|
|
||||||
MULTIPART_THRESHOLD = 100 * 1024 * 1024
|
|
||||||
# Chunk size for multipart upload (10MB)
|
|
||||||
MULTIPART_CHUNK_SIZE = 10 * 1024 * 1024
|
|
||||||
# Chunk size for streaming hash computation
|
|
||||||
HASH_CHUNK_SIZE = 8 * 1024 * 1024
|
|
||||||
|
|
||||||
|
|
||||||
class S3Storage:
|
class S3Storage:
|
||||||
@@ -31,23 +22,12 @@ class S3Storage:
|
|||||||
config=config,
|
config=config,
|
||||||
)
|
)
|
||||||
self.bucket = settings.s3_bucket
|
self.bucket = settings.s3_bucket
|
||||||
# Store active multipart uploads for resumable support
|
|
||||||
self._active_uploads: Dict[str, Dict[str, Any]] = {}
|
|
||||||
|
|
||||||
def store(self, file: BinaryIO, content_length: Optional[int] = None) -> Tuple[str, int, str]:
|
def store(self, file: BinaryIO) -> Tuple[str, int]:
|
||||||
"""
|
"""
|
||||||
Store a file and return its SHA256 hash, size, and s3_key.
|
Store a file and return its SHA256 hash and size.
|
||||||
Content-addressable: if the file already exists, just return the hash.
|
Content-addressable: if the file already exists, just return the hash.
|
||||||
Uses multipart upload for files larger than MULTIPART_THRESHOLD.
|
|
||||||
"""
|
"""
|
||||||
# For small files or unknown size, use the simple approach
|
|
||||||
if content_length is None or content_length < MULTIPART_THRESHOLD:
|
|
||||||
return self._store_simple(file)
|
|
||||||
else:
|
|
||||||
return self._store_multipart(file, content_length)
|
|
||||||
|
|
||||||
def _store_simple(self, file: BinaryIO) -> Tuple[str, int, str]:
|
|
||||||
"""Store a small file using simple put_object"""
|
|
||||||
# Read file and compute hash
|
# Read file and compute hash
|
||||||
content = file.read()
|
content = file.read()
|
||||||
sha256_hash = hashlib.sha256(content).hexdigest()
|
sha256_hash = hashlib.sha256(content).hexdigest()
|
||||||
@@ -65,300 +45,15 @@ class S3Storage:
|
|||||||
|
|
||||||
return sha256_hash, size, s3_key
|
return sha256_hash, size, s3_key
|
||||||
|
|
||||||
def _store_multipart(self, file: BinaryIO, content_length: int) -> Tuple[str, int, str]:
|
|
||||||
"""Store a large file using S3 multipart upload with streaming hash computation"""
|
|
||||||
# First pass: compute hash by streaming through file
|
|
||||||
hasher = hashlib.sha256()
|
|
||||||
size = 0
|
|
||||||
|
|
||||||
# Read file in chunks to compute hash
|
|
||||||
while True:
|
|
||||||
chunk = file.read(HASH_CHUNK_SIZE)
|
|
||||||
if not chunk:
|
|
||||||
break
|
|
||||||
hasher.update(chunk)
|
|
||||||
size += len(chunk)
|
|
||||||
|
|
||||||
sha256_hash = hasher.hexdigest()
|
|
||||||
s3_key = f"fruits/{sha256_hash[:2]}/{sha256_hash[2:4]}/{sha256_hash}"
|
|
||||||
|
|
||||||
# Check if already exists (deduplication)
|
|
||||||
if self._exists(s3_key):
|
|
||||||
return sha256_hash, size, s3_key
|
|
||||||
|
|
||||||
# Seek back to start for upload
|
|
||||||
file.seek(0)
|
|
||||||
|
|
||||||
# Start multipart upload
|
|
||||||
mpu = self.client.create_multipart_upload(Bucket=self.bucket, Key=s3_key)
|
|
||||||
upload_id = mpu["UploadId"]
|
|
||||||
|
|
||||||
try:
|
|
||||||
parts = []
|
|
||||||
part_number = 1
|
|
||||||
|
|
||||||
while True:
|
|
||||||
chunk = file.read(MULTIPART_CHUNK_SIZE)
|
|
||||||
if not chunk:
|
|
||||||
break
|
|
||||||
|
|
||||||
response = self.client.upload_part(
|
|
||||||
Bucket=self.bucket,
|
|
||||||
Key=s3_key,
|
|
||||||
UploadId=upload_id,
|
|
||||||
PartNumber=part_number,
|
|
||||||
Body=chunk,
|
|
||||||
)
|
|
||||||
parts.append({
|
|
||||||
"PartNumber": part_number,
|
|
||||||
"ETag": response["ETag"],
|
|
||||||
})
|
|
||||||
part_number += 1
|
|
||||||
|
|
||||||
# Complete multipart upload
|
|
||||||
self.client.complete_multipart_upload(
|
|
||||||
Bucket=self.bucket,
|
|
||||||
Key=s3_key,
|
|
||||||
UploadId=upload_id,
|
|
||||||
MultipartUpload={"Parts": parts},
|
|
||||||
)
|
|
||||||
|
|
||||||
return sha256_hash, size, s3_key
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
# Abort multipart upload on failure
|
|
||||||
logger.error(f"Multipart upload failed: {e}")
|
|
||||||
self.client.abort_multipart_upload(
|
|
||||||
Bucket=self.bucket,
|
|
||||||
Key=s3_key,
|
|
||||||
UploadId=upload_id,
|
|
||||||
)
|
|
||||||
raise
|
|
||||||
|
|
||||||
def store_streaming(self, chunks: Generator[bytes, None, None]) -> Tuple[str, int, str]:
|
|
||||||
"""
|
|
||||||
Store a file from a stream of chunks.
|
|
||||||
First accumulates to compute hash, then uploads.
|
|
||||||
For truly large files, consider using initiate_resumable_upload instead.
|
|
||||||
"""
|
|
||||||
# Accumulate chunks and compute hash
|
|
||||||
hasher = hashlib.sha256()
|
|
||||||
all_chunks = []
|
|
||||||
size = 0
|
|
||||||
|
|
||||||
for chunk in chunks:
|
|
||||||
hasher.update(chunk)
|
|
||||||
all_chunks.append(chunk)
|
|
||||||
size += len(chunk)
|
|
||||||
|
|
||||||
sha256_hash = hasher.hexdigest()
|
|
||||||
s3_key = f"fruits/{sha256_hash[:2]}/{sha256_hash[2:4]}/{sha256_hash}"
|
|
||||||
|
|
||||||
# Check if already exists
|
|
||||||
if self._exists(s3_key):
|
|
||||||
return sha256_hash, size, s3_key
|
|
||||||
|
|
||||||
# Upload based on size
|
|
||||||
if size < MULTIPART_THRESHOLD:
|
|
||||||
content = b"".join(all_chunks)
|
|
||||||
self.client.put_object(Bucket=self.bucket, Key=s3_key, Body=content)
|
|
||||||
else:
|
|
||||||
# Use multipart for large files
|
|
||||||
mpu = self.client.create_multipart_upload(Bucket=self.bucket, Key=s3_key)
|
|
||||||
upload_id = mpu["UploadId"]
|
|
||||||
|
|
||||||
try:
|
|
||||||
parts = []
|
|
||||||
part_number = 1
|
|
||||||
buffer = b""
|
|
||||||
|
|
||||||
for chunk in all_chunks:
|
|
||||||
buffer += chunk
|
|
||||||
while len(buffer) >= MULTIPART_CHUNK_SIZE:
|
|
||||||
part_data = buffer[:MULTIPART_CHUNK_SIZE]
|
|
||||||
buffer = buffer[MULTIPART_CHUNK_SIZE:]
|
|
||||||
|
|
||||||
response = self.client.upload_part(
|
|
||||||
Bucket=self.bucket,
|
|
||||||
Key=s3_key,
|
|
||||||
UploadId=upload_id,
|
|
||||||
PartNumber=part_number,
|
|
||||||
Body=part_data,
|
|
||||||
)
|
|
||||||
parts.append({
|
|
||||||
"PartNumber": part_number,
|
|
||||||
"ETag": response["ETag"],
|
|
||||||
})
|
|
||||||
part_number += 1
|
|
||||||
|
|
||||||
# Upload remaining buffer
|
|
||||||
if buffer:
|
|
||||||
response = self.client.upload_part(
|
|
||||||
Bucket=self.bucket,
|
|
||||||
Key=s3_key,
|
|
||||||
UploadId=upload_id,
|
|
||||||
PartNumber=part_number,
|
|
||||||
Body=buffer,
|
|
||||||
)
|
|
||||||
parts.append({
|
|
||||||
"PartNumber": part_number,
|
|
||||||
"ETag": response["ETag"],
|
|
||||||
})
|
|
||||||
|
|
||||||
self.client.complete_multipart_upload(
|
|
||||||
Bucket=self.bucket,
|
|
||||||
Key=s3_key,
|
|
||||||
UploadId=upload_id,
|
|
||||||
MultipartUpload={"Parts": parts},
|
|
||||||
)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Streaming multipart upload failed: {e}")
|
|
||||||
self.client.abort_multipart_upload(
|
|
||||||
Bucket=self.bucket,
|
|
||||||
Key=s3_key,
|
|
||||||
UploadId=upload_id,
|
|
||||||
)
|
|
||||||
raise
|
|
||||||
|
|
||||||
return sha256_hash, size, s3_key
|
|
||||||
|
|
||||||
def initiate_resumable_upload(self, expected_hash: str) -> Dict[str, Any]:
|
|
||||||
"""
|
|
||||||
Initiate a resumable upload session.
|
|
||||||
Returns upload session info including upload_id.
|
|
||||||
"""
|
|
||||||
s3_key = f"fruits/{expected_hash[:2]}/{expected_hash[2:4]}/{expected_hash}"
|
|
||||||
|
|
||||||
# Check if already exists
|
|
||||||
if self._exists(s3_key):
|
|
||||||
return {
|
|
||||||
"upload_id": None,
|
|
||||||
"s3_key": s3_key,
|
|
||||||
"already_exists": True,
|
|
||||||
"parts": [],
|
|
||||||
}
|
|
||||||
|
|
||||||
mpu = self.client.create_multipart_upload(Bucket=self.bucket, Key=s3_key)
|
|
||||||
upload_id = mpu["UploadId"]
|
|
||||||
|
|
||||||
session = {
|
|
||||||
"upload_id": upload_id,
|
|
||||||
"s3_key": s3_key,
|
|
||||||
"already_exists": False,
|
|
||||||
"parts": [],
|
|
||||||
"expected_hash": expected_hash,
|
|
||||||
}
|
|
||||||
self._active_uploads[upload_id] = session
|
|
||||||
return session
|
|
||||||
|
|
||||||
def upload_part(self, upload_id: str, part_number: int, data: bytes) -> Dict[str, Any]:
|
|
||||||
"""
|
|
||||||
Upload a part for a resumable upload.
|
|
||||||
Returns part info including ETag.
|
|
||||||
"""
|
|
||||||
session = self._active_uploads.get(upload_id)
|
|
||||||
if not session:
|
|
||||||
raise ValueError(f"Unknown upload session: {upload_id}")
|
|
||||||
|
|
||||||
response = self.client.upload_part(
|
|
||||||
Bucket=self.bucket,
|
|
||||||
Key=session["s3_key"],
|
|
||||||
UploadId=upload_id,
|
|
||||||
PartNumber=part_number,
|
|
||||||
Body=data,
|
|
||||||
)
|
|
||||||
|
|
||||||
part_info = {
|
|
||||||
"PartNumber": part_number,
|
|
||||||
"ETag": response["ETag"],
|
|
||||||
}
|
|
||||||
session["parts"].append(part_info)
|
|
||||||
return part_info
|
|
||||||
|
|
||||||
def complete_resumable_upload(self, upload_id: str) -> Tuple[str, str]:
|
|
||||||
"""
|
|
||||||
Complete a resumable upload.
|
|
||||||
Returns (sha256_hash, s3_key).
|
|
||||||
"""
|
|
||||||
session = self._active_uploads.get(upload_id)
|
|
||||||
if not session:
|
|
||||||
raise ValueError(f"Unknown upload session: {upload_id}")
|
|
||||||
|
|
||||||
# Sort parts by part number
|
|
||||||
sorted_parts = sorted(session["parts"], key=lambda x: x["PartNumber"])
|
|
||||||
|
|
||||||
self.client.complete_multipart_upload(
|
|
||||||
Bucket=self.bucket,
|
|
||||||
Key=session["s3_key"],
|
|
||||||
UploadId=upload_id,
|
|
||||||
MultipartUpload={"Parts": sorted_parts},
|
|
||||||
)
|
|
||||||
|
|
||||||
# Clean up session
|
|
||||||
del self._active_uploads[upload_id]
|
|
||||||
|
|
||||||
return session["expected_hash"], session["s3_key"]
|
|
||||||
|
|
||||||
def abort_resumable_upload(self, upload_id: str):
|
|
||||||
"""Abort a resumable upload"""
|
|
||||||
session = self._active_uploads.get(upload_id)
|
|
||||||
if session:
|
|
||||||
self.client.abort_multipart_upload(
|
|
||||||
Bucket=self.bucket,
|
|
||||||
Key=session["s3_key"],
|
|
||||||
UploadId=upload_id,
|
|
||||||
)
|
|
||||||
del self._active_uploads[upload_id]
|
|
||||||
|
|
||||||
def list_upload_parts(self, upload_id: str) -> list:
|
|
||||||
"""List uploaded parts for a resumable upload (for resume support)"""
|
|
||||||
session = self._active_uploads.get(upload_id)
|
|
||||||
if not session:
|
|
||||||
raise ValueError(f"Unknown upload session: {upload_id}")
|
|
||||||
|
|
||||||
response = self.client.list_parts(
|
|
||||||
Bucket=self.bucket,
|
|
||||||
Key=session["s3_key"],
|
|
||||||
UploadId=upload_id,
|
|
||||||
)
|
|
||||||
return response.get("Parts", [])
|
|
||||||
|
|
||||||
def get(self, s3_key: str) -> bytes:
|
def get(self, s3_key: str) -> bytes:
|
||||||
"""Retrieve a file by its S3 key"""
|
"""Retrieve a file by its S3 key"""
|
||||||
response = self.client.get_object(Bucket=self.bucket, Key=s3_key)
|
response = self.client.get_object(Bucket=self.bucket, Key=s3_key)
|
||||||
return response["Body"].read()
|
return response["Body"].read()
|
||||||
|
|
||||||
def get_stream(self, s3_key: str, range_header: Optional[str] = None):
|
def get_stream(self, s3_key: str):
|
||||||
"""
|
"""Get a streaming response for a file"""
|
||||||
Get a streaming response for a file.
|
response = self.client.get_object(Bucket=self.bucket, Key=s3_key)
|
||||||
Supports range requests for partial downloads.
|
return response["Body"]
|
||||||
Returns (stream, content_length, content_range, accept_ranges)
|
|
||||||
"""
|
|
||||||
kwargs = {"Bucket": self.bucket, "Key": s3_key}
|
|
||||||
|
|
||||||
if range_header:
|
|
||||||
kwargs["Range"] = range_header
|
|
||||||
|
|
||||||
response = self.client.get_object(**kwargs)
|
|
||||||
|
|
||||||
content_length = response.get("ContentLength", 0)
|
|
||||||
content_range = response.get("ContentRange")
|
|
||||||
|
|
||||||
return response["Body"], content_length, content_range
|
|
||||||
|
|
||||||
def get_object_info(self, s3_key: str) -> Dict[str, Any]:
|
|
||||||
"""Get object metadata without downloading content"""
|
|
||||||
try:
|
|
||||||
response = self.client.head_object(Bucket=self.bucket, Key=s3_key)
|
|
||||||
return {
|
|
||||||
"size": response.get("ContentLength", 0),
|
|
||||||
"content_type": response.get("ContentType"),
|
|
||||||
"last_modified": response.get("LastModified"),
|
|
||||||
"etag": response.get("ETag"),
|
|
||||||
}
|
|
||||||
except ClientError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def _exists(self, s3_key: str) -> bool:
|
def _exists(self, s3_key: str) -> bool:
|
||||||
"""Check if an object exists"""
|
"""Check if an object exists"""
|
||||||
|
|||||||
@@ -2,174 +2,64 @@
|
|||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
background: var(--bg-primary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Header */
|
|
||||||
.header {
|
.header {
|
||||||
background: var(--bg-secondary);
|
background-color: var(--primary);
|
||||||
border-bottom: 1px solid var(--border-primary);
|
color: white;
|
||||||
padding: 0;
|
padding: 1rem 0;
|
||||||
position: sticky;
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||||
top: 0;
|
|
||||||
z-index: 100;
|
|
||||||
backdrop-filter: blur(12px);
|
|
||||||
background: rgba(17, 17, 19, 0.85);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-content {
|
.header-content {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 64px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Logo */
|
|
||||||
.logo {
|
.logo {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 12px;
|
gap: 0.5rem;
|
||||||
color: var(--text-primary);
|
color: white;
|
||||||
font-size: 1.25rem;
|
font-size: 1.5rem;
|
||||||
font-weight: 600;
|
font-weight: bold;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
transition: opacity var(--transition-fast);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo:hover {
|
.logo:hover {
|
||||||
opacity: 0.9;
|
text-decoration: none;
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo-icon {
|
.logo-icon {
|
||||||
display: flex;
|
font-size: 2rem;
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 40px;
|
|
||||||
height: 40px;
|
|
||||||
background: var(--accent-gradient);
|
|
||||||
border-radius: var(--radius-md);
|
|
||||||
color: white;
|
|
||||||
box-shadow: var(--shadow-glow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo-text {
|
|
||||||
letter-spacing: -0.02em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Navigation */
|
|
||||||
.nav {
|
.nav {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 1.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav a {
|
.nav a {
|
||||||
display: flex;
|
color: white;
|
||||||
align-items: center;
|
opacity: 0.9;
|
||||||
gap: 8px;
|
|
||||||
padding: 8px 16px;
|
|
||||||
color: var(--text-primary);
|
|
||||||
font-size: 0.875rem;
|
|
||||||
font-weight: 500;
|
|
||||||
border-radius: var(--radius-md);
|
|
||||||
transition: all var(--transition-fast);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav a:hover {
|
.nav a:hover {
|
||||||
color: var(--text-primary);
|
|
||||||
background: var(--bg-hover);
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav a.active {
|
|
||||||
color: var(--accent-primary);
|
|
||||||
background: rgba(16, 185, 129, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav a svg {
|
|
||||||
opacity: 0.8;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav a:hover svg,
|
|
||||||
.nav a.active svg {
|
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-link-muted {
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Main content */
|
|
||||||
.main {
|
.main {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 32px 0 64px;
|
padding: 2rem 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Footer */
|
|
||||||
.footer {
|
.footer {
|
||||||
background: var(--bg-secondary);
|
background-color: var(--primary-dark);
|
||||||
border-top: 1px solid var(--border-primary);
|
color: white;
|
||||||
padding: 24px 0;
|
padding: 1rem 0;
|
||||||
}
|
|
||||||
|
|
||||||
.footer-content {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer-brand {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer-logo {
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer-tagline {
|
|
||||||
color: var(--text-secondary);
|
|
||||||
font-size: 0.875rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer-links {
|
|
||||||
display: flex;
|
|
||||||
gap: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer-links a {
|
|
||||||
color: var(--text-secondary);
|
|
||||||
font-size: 0.875rem;
|
|
||||||
transition: color var(--transition-fast);
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer-links a:hover {
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Responsive */
|
|
||||||
@media (max-width: 640px) {
|
|
||||||
.header-content {
|
|
||||||
height: 56px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo-text {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav a span {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer-content {
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 16px;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
opacity: 0.9;
|
||||||
|
font-size: 0.875rem;
|
||||||
.footer-brand {
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 4px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import { Link, useLocation } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import './Layout.css';
|
import './Layout.css';
|
||||||
|
|
||||||
interface LayoutProps {
|
interface LayoutProps {
|
||||||
@@ -7,48 +7,16 @@ interface LayoutProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Layout({ children }: LayoutProps) {
|
function Layout({ children }: LayoutProps) {
|
||||||
const location = useLocation();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="layout">
|
<div className="layout">
|
||||||
<header className="header">
|
<header className="header">
|
||||||
<div className="container header-content">
|
<div className="container header-content">
|
||||||
<Link to="/" className="logo">
|
<Link to="/" className="logo">
|
||||||
<div className="logo-icon">
|
<span className="logo-icon">🌳</span>
|
||||||
<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
{/* Three trees representing an orchard */}
|
|
||||||
{/* Left tree */}
|
|
||||||
<ellipse cx="6" cy="9" rx="4" ry="5" fill="currentColor" opacity="0.7"/>
|
|
||||||
<rect x="5" y="13" width="2" height="5" fill="currentColor"/>
|
|
||||||
{/* Center tree (larger) */}
|
|
||||||
<ellipse cx="12" cy="7" rx="5" ry="6" fill="currentColor"/>
|
|
||||||
<rect x="11" y="12" width="2" height="6" fill="currentColor"/>
|
|
||||||
{/* Right tree */}
|
|
||||||
<ellipse cx="18" cy="9" rx="4" ry="5" fill="currentColor" opacity="0.7"/>
|
|
||||||
<rect x="17" y="13" width="2" height="5" fill="currentColor"/>
|
|
||||||
{/* Ground line */}
|
|
||||||
<line x1="2" y1="18" x2="22" y2="18" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" opacity="0.5"/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<span className="logo-text">Orchard</span>
|
<span className="logo-text">Orchard</span>
|
||||||
</Link>
|
</Link>
|
||||||
<nav className="nav">
|
<nav className="nav">
|
||||||
<Link to="/" className={location.pathname === '/' ? 'active' : ''}>
|
<Link to="/">Groves</Link>
|
||||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
||||||
<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>
|
|
||||||
<polyline points="9,22 9,12 15,12 15,22"/>
|
|
||||||
</svg>
|
|
||||||
Projects
|
|
||||||
</Link>
|
|
||||||
<a href="/docs" className="nav-link-muted">
|
|
||||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
||||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
||||||
<polyline points="14,2 14,8 20,8"/>
|
|
||||||
<line x1="16" y1="13" x2="8" y2="13"/>
|
|
||||||
<line x1="16" y1="17" x2="8" y2="17"/>
|
|
||||||
</svg>
|
|
||||||
Docs
|
|
||||||
</a>
|
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
@@ -58,15 +26,8 @@ function Layout({ children }: LayoutProps) {
|
|||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<footer className="footer">
|
<footer className="footer">
|
||||||
<div className="container footer-content">
|
<div className="container">
|
||||||
<div className="footer-brand">
|
<p>Orchard - Content-Addressable Storage System</p>
|
||||||
<span className="footer-logo">Orchard</span>
|
|
||||||
<span className="footer-tagline">Content-Addressable Storage</span>
|
|
||||||
</div>
|
|
||||||
<div className="footer-links">
|
|
||||||
<a href="/docs">Documentation</a>
|
|
||||||
<a href="/api/v1">API</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,97 +5,34 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
/* Dark mode color palette */
|
--primary: #2d5a27;
|
||||||
--bg-primary: #0a0a0b;
|
--primary-light: #4a8c3f;
|
||||||
--bg-secondary: #111113;
|
--primary-dark: #1e3d1a;
|
||||||
--bg-tertiary: #1a1a1d;
|
--secondary: #8b4513;
|
||||||
--bg-elevated: #222225;
|
--background: #f5f5f0;
|
||||||
--bg-hover: #2a2a2e;
|
--surface: #ffffff;
|
||||||
|
--text: #333333;
|
||||||
/* Accent colors - Green/Emerald theme */
|
--text-light: #666666;
|
||||||
--accent-primary: #10b981;
|
--border: #e0e0e0;
|
||||||
--accent-primary-hover: #34d399;
|
--success: #28a745;
|
||||||
--accent-secondary: #059669;
|
--error: #dc3545;
|
||||||
--accent-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
|
--warning: #ffc107;
|
||||||
|
|
||||||
/* Text colors - improved contrast */
|
|
||||||
--text-primary: #f9fafb;
|
|
||||||
--text-secondary: #d1d5db;
|
|
||||||
--text-tertiary: #9ca3af;
|
|
||||||
--text-muted: #6b7280;
|
|
||||||
|
|
||||||
/* Border colors */
|
|
||||||
--border-primary: #27272a;
|
|
||||||
--border-secondary: #3f3f46;
|
|
||||||
--border-accent: #10b981;
|
|
||||||
|
|
||||||
/* Status colors */
|
|
||||||
--success: #22c55e;
|
|
||||||
--success-bg: rgba(34, 197, 94, 0.1);
|
|
||||||
--error: #ef4444;
|
|
||||||
--error-bg: rgba(239, 68, 68, 0.1);
|
|
||||||
--warning: #f59e0b;
|
|
||||||
--warning-bg: rgba(245, 158, 11, 0.1);
|
|
||||||
|
|
||||||
/* Shadows */
|
|
||||||
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
|
|
||||||
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
|
|
||||||
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
|
|
||||||
--shadow-glow: 0 0 20px rgba(16, 185, 129, 0.3);
|
|
||||||
|
|
||||||
/* Transitions */
|
|
||||||
--transition-fast: 150ms ease;
|
|
||||||
--transition-normal: 250ms ease;
|
|
||||||
--transition-slow: 350ms ease;
|
|
||||||
|
|
||||||
/* Border radius */
|
|
||||||
--radius-sm: 6px;
|
|
||||||
--radius-md: 8px;
|
|
||||||
--radius-lg: 12px;
|
|
||||||
--radius-xl: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
html {
|
|
||||||
color-scheme: dark;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
||||||
background-color: var(--bg-primary);
|
background-color: var(--background);
|
||||||
color: var(--text-primary);
|
color: var(--text);
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
font-size: 14px;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
-moz-osx-font-smoothing: grayscale;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Scrollbar styling */
|
|
||||||
::-webkit-scrollbar {
|
|
||||||
width: 8px;
|
|
||||||
height: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-scrollbar-track {
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb {
|
|
||||||
background: var(--border-secondary);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb:hover {
|
|
||||||
background: var(--text-tertiary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: var(--accent-primary);
|
color: var(--primary);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
transition: color var(--transition-fast);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a:hover {
|
a:hover {
|
||||||
color: var(--accent-primary-hover);
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
@@ -104,13 +41,7 @@ button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
max-width: 1280px;
|
max-width: 1200px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 0 24px;
|
padding: 0 20px;
|
||||||
}
|
|
||||||
|
|
||||||
/* Selection */
|
|
||||||
::selection {
|
|
||||||
background: var(--accent-primary);
|
|
||||||
color: white;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
/* Page Layout */
|
|
||||||
.home {
|
.home {
|
||||||
max-width: 1000px;
|
max-width: 1000px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
@@ -8,92 +7,71 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 32px;
|
margin-bottom: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-header h1 {
|
.page-header h1 {
|
||||||
font-size: 2rem;
|
font-size: 2rem;
|
||||||
font-weight: 700;
|
color: var(--primary-dark);
|
||||||
color: var(--text-primary);
|
|
||||||
letter-spacing: -0.02em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Buttons */
|
|
||||||
.btn {
|
.btn {
|
||||||
display: inline-flex;
|
padding: 0.625rem 1.25rem;
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
padding: 10px 20px;
|
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: var(--radius-md);
|
border-radius: 6px;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
transition: all var(--transition-fast);
|
transition: all 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary {
|
.btn-primary {
|
||||||
background: var(--accent-gradient);
|
background-color: var(--primary);
|
||||||
color: white;
|
color: white;
|
||||||
box-shadow: var(--shadow-sm), 0 0 20px rgba(16, 185, 129, 0.2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary:hover {
|
.btn-primary:hover {
|
||||||
transform: translateY(-1px);
|
background-color: var(--primary-dark);
|
||||||
box-shadow: var(--shadow-md), 0 0 30px rgba(16, 185, 129, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary:active {
|
|
||||||
transform: translateY(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary:disabled {
|
.btn-primary:disabled {
|
||||||
opacity: 0.5;
|
opacity: 0.6;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
transform: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-secondary {
|
.btn-secondary {
|
||||||
background: var(--bg-tertiary);
|
background-color: var(--border);
|
||||||
color: var(--text-secondary);
|
color: var(--text);
|
||||||
border: 1px solid var(--border-primary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-secondary:hover {
|
.btn-secondary:hover {
|
||||||
background: var(--bg-hover);
|
background-color: #d0d0d0;
|
||||||
color: var(--text-primary);
|
|
||||||
border-color: var(--border-secondary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cards */
|
|
||||||
.card {
|
.card {
|
||||||
background: var(--bg-secondary);
|
background-color: var(--surface);
|
||||||
border: 1px solid var(--border-primary);
|
border: 1px solid var(--border);
|
||||||
border-radius: var(--radius-lg);
|
border-radius: 8px;
|
||||||
padding: 24px;
|
padding: 1.5rem;
|
||||||
transition: all var(--transition-normal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Forms */
|
|
||||||
.form {
|
.form {
|
||||||
margin-bottom: 32px;
|
margin-bottom: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form h3 {
|
.form h3 {
|
||||||
margin-bottom: 20px;
|
margin-bottom: 1rem;
|
||||||
color: var(--text-primary);
|
color: var(--primary-dark);
|
||||||
font-size: 1.125rem;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-group {
|
.form-group {
|
||||||
margin-bottom: 16px;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-group label {
|
.form-group label {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 0.375rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: var(--text-secondary);
|
color: var(--text-light);
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,138 +80,82 @@
|
|||||||
.form-group select,
|
.form-group select,
|
||||||
.form-group textarea {
|
.form-group textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 12px 16px;
|
padding: 0.625rem;
|
||||||
background: var(--bg-tertiary);
|
border: 1px solid var(--border);
|
||||||
border: 1px solid var(--border-primary);
|
border-radius: 6px;
|
||||||
border-radius: var(--radius-md);
|
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
color: var(--text-primary);
|
|
||||||
transition: all var(--transition-fast);
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group input::placeholder {
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-group input:focus,
|
.form-group input:focus,
|
||||||
.form-group select:focus,
|
.form-group select:focus,
|
||||||
.form-group textarea:focus {
|
.form-group textarea:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
border-color: var(--accent-primary);
|
border-color: var(--primary);
|
||||||
box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
|
box-shadow: 0 0 0 3px rgba(45, 90, 39, 0.1);
|
||||||
background: var(--bg-elevated);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-group.checkbox label {
|
.form-group.checkbox label {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 10px;
|
gap: 0.5rem;
|
||||||
cursor: pointer;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group.checkbox input[type="checkbox"] {
|
|
||||||
width: 18px;
|
|
||||||
height: 18px;
|
|
||||||
accent-color: var(--accent-primary);
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Messages */
|
.form-group.checkbox input {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.error-message {
|
.error-message {
|
||||||
background: var(--error-bg);
|
background-color: #fef2f2;
|
||||||
border: 1px solid rgba(239, 68, 68, 0.2);
|
border: 1px solid #fecaca;
|
||||||
color: var(--error);
|
color: var(--error);
|
||||||
padding: 12px 16px;
|
padding: 0.75rem 1rem;
|
||||||
border-radius: var(--radius-md);
|
border-radius: 6px;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 1rem;
|
||||||
font-size: 0.875rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.success-message {
|
|
||||||
background: var(--success-bg);
|
|
||||||
border: 1px solid rgba(34, 197, 94, 0.2);
|
|
||||||
color: var(--success);
|
|
||||||
padding: 12px 16px;
|
|
||||||
border-radius: var(--radius-md);
|
|
||||||
margin-bottom: 16px;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Loading */
|
|
||||||
.loading {
|
.loading {
|
||||||
display: flex;
|
text-align: center;
|
||||||
align-items: center;
|
padding: 3rem;
|
||||||
justify-content: center;
|
color: var(--text-light);
|
||||||
padding: 64px;
|
|
||||||
color: var(--text-tertiary);
|
|
||||||
font-size: 0.875rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Empty State */
|
|
||||||
.empty-state {
|
.empty-state {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 64px 32px;
|
padding: 3rem;
|
||||||
color: var(--text-tertiary);
|
color: var(--text-light);
|
||||||
background: var(--bg-secondary);
|
background-color: var(--surface);
|
||||||
border: 1px dashed var(--border-secondary);
|
border: 1px dashed var(--border);
|
||||||
border-radius: var(--radius-lg);
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-state p {
|
|
||||||
font-size: 0.9375rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Project Grid */
|
|
||||||
.project-grid {
|
.project-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
||||||
gap: 16px;
|
gap: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.project-card {
|
.project-card {
|
||||||
display: block;
|
display: block;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
position: relative;
|
transition: transform 0.2s, box-shadow 0.2s;
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.project-card::before {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
background: var(--accent-gradient);
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity var(--transition-normal);
|
|
||||||
border-radius: var(--radius-lg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.project-card:hover {
|
.project-card:hover {
|
||||||
border-color: var(--border-secondary);
|
|
||||||
transform: translateY(-2px);
|
transform: translateY(-2px);
|
||||||
box-shadow: var(--shadow-lg);
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||||
color: inherit;
|
text-decoration: none;
|
||||||
}
|
|
||||||
|
|
||||||
.project-card:hover::before {
|
|
||||||
opacity: 0.03;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.project-card h3 {
|
.project-card h3 {
|
||||||
color: var(--text-primary);
|
color: var(--primary);
|
||||||
font-size: 1.125rem;
|
margin-bottom: 0.5rem;
|
||||||
font-weight: 600;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.project-card p {
|
.project-card p {
|
||||||
color: var(--text-secondary);
|
color: var(--text-light);
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 1rem;
|
||||||
line-height: 1.5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.project-meta {
|
.project-meta {
|
||||||
@@ -241,63 +163,24 @@
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
padding-top: 16px;
|
|
||||||
border-top: 1px solid var(--border-primary);
|
|
||||||
margin-top: auto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Badges */
|
|
||||||
.badge {
|
.badge {
|
||||||
padding: 4px 10px;
|
padding: 0.25rem 0.5rem;
|
||||||
border-radius: 100px;
|
border-radius: 4px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 0.75rem;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.02em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.badge-public {
|
.badge-public {
|
||||||
background: var(--success-bg);
|
background-color: #dcfce7;
|
||||||
color: var(--success);
|
color: #166534;
|
||||||
border: 1px solid rgba(34, 197, 94, 0.2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.badge-private {
|
.badge-private {
|
||||||
background: var(--warning-bg);
|
background-color: #fef3c7;
|
||||||
color: var(--warning);
|
color: #92400e;
|
||||||
border: 1px solid rgba(245, 158, 11, 0.2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.date {
|
.date {
|
||||||
color: var(--text-muted);
|
color: var(--text-light);
|
||||||
}
|
|
||||||
|
|
||||||
/* Breadcrumb */
|
|
||||||
.breadcrumb {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
margin-bottom: 24px;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
color: var(--text-tertiary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.breadcrumb a {
|
|
||||||
color: var(--text-secondary);
|
|
||||||
transition: color var(--transition-fast);
|
|
||||||
}
|
|
||||||
|
|
||||||
.breadcrumb a:hover {
|
|
||||||
color: var(--accent-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.breadcrumb span {
|
|
||||||
color: var(--text-primary);
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.description {
|
|
||||||
color: var(--text-secondary);
|
|
||||||
margin-top: 4px;
|
|
||||||
font-size: 0.9375rem;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,44 @@
|
|||||||
/* Upload Section */
|
.breadcrumb {
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
color: var(--text-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.breadcrumb a {
|
||||||
|
color: var(--primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.breadcrumb span {
|
||||||
|
color: var(--text);
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
color: var(--text-light);
|
||||||
|
margin-top: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success-message {
|
||||||
|
background-color: #f0fdf4;
|
||||||
|
border: 1px solid #bbf7d0;
|
||||||
|
color: var(--success);
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
border-radius: 6px;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
.upload-section {
|
.upload-section {
|
||||||
margin-bottom: 32px;
|
margin-bottom: 2rem;
|
||||||
background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(5, 150, 105, 0.05) 100%);
|
|
||||||
border: 1px solid rgba(16, 185, 129, 0.2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.upload-section h3 {
|
.upload-section h3 {
|
||||||
margin-bottom: 20px;
|
margin-bottom: 1rem;
|
||||||
color: var(--text-primary);
|
color: var(--primary-dark);
|
||||||
font-size: 1rem;
|
|
||||||
font-weight: 600;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload-section h3::before {
|
|
||||||
content: '';
|
|
||||||
display: block;
|
|
||||||
width: 4px;
|
|
||||||
height: 20px;
|
|
||||||
background: var(--accent-gradient);
|
|
||||||
border-radius: 2px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.upload-form {
|
.upload-form {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 16px;
|
gap: 1rem;
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
@@ -37,42 +49,17 @@
|
|||||||
min-width: 200px;
|
min-width: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.upload-form .form-group input[type="file"] {
|
|
||||||
padding: 10px 16px;
|
|
||||||
background: var(--bg-tertiary);
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload-form .form-group input[type="file"]::file-selector-button {
|
|
||||||
background: var(--accent-gradient);
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
padding: 6px 12px;
|
|
||||||
border-radius: var(--radius-sm);
|
|
||||||
margin-right: 12px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-weight: 500;
|
|
||||||
font-size: 0.8125rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Section Headers */
|
|
||||||
h2 {
|
h2 {
|
||||||
margin-bottom: 16px;
|
margin-bottom: 1rem;
|
||||||
color: var(--text-primary);
|
color: var(--primary-dark);
|
||||||
font-size: 1.25rem;
|
|
||||||
font-weight: 600;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tags Table */
|
|
||||||
.tags-table {
|
.tags-table {
|
||||||
background: var(--bg-secondary);
|
background-color: var(--surface);
|
||||||
border: 1px solid var(--border-primary);
|
border: 1px solid var(--border);
|
||||||
border-radius: var(--radius-lg);
|
border-radius: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin-bottom: 32px;
|
margin-bottom: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tags-table table {
|
.tags-table table {
|
||||||
@@ -82,146 +69,63 @@ h2 {
|
|||||||
|
|
||||||
.tags-table th,
|
.tags-table th,
|
||||||
.tags-table td {
|
.tags-table td {
|
||||||
padding: 14px 20px;
|
padding: 0.875rem 1rem;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
border-bottom: 1px solid var(--border-primary);
|
border-bottom: 1px solid var(--border);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tags-table th {
|
.tags-table th {
|
||||||
background: var(--bg-tertiary);
|
background-color: #f9f9f9;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
letter-spacing: 0.05em;
|
color: var(--text-light);
|
||||||
color: var(--text-tertiary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tags-table tr:last-child td {
|
.tags-table tr:last-child td {
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tags-table tbody tr {
|
.tags-table tr:hover {
|
||||||
transition: background var(--transition-fast);
|
background-color: #f9f9f9;
|
||||||
}
|
|
||||||
|
|
||||||
.tags-table tbody tr:hover {
|
|
||||||
background: var(--bg-tertiary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.tags-table td strong {
|
|
||||||
color: var(--accent-primary);
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.artifact-id {
|
.artifact-id {
|
||||||
font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
|
font-family: monospace;
|
||||||
font-size: 0.8125rem;
|
font-size: 0.875rem;
|
||||||
color: var(--text-tertiary);
|
color: var(--text-light);
|
||||||
background: var(--bg-tertiary);
|
|
||||||
padding: 4px 8px;
|
|
||||||
border-radius: var(--radius-sm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-small {
|
.btn-small {
|
||||||
padding: 6px 12px;
|
padding: 0.375rem 0.75rem;
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Usage Section */
|
|
||||||
.usage-section {
|
.usage-section {
|
||||||
margin-top: 32px;
|
margin-top: 2rem;
|
||||||
background: var(--bg-secondary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.usage-section h3 {
|
.usage-section h3 {
|
||||||
margin-bottom: 12px;
|
margin-bottom: 0.5rem;
|
||||||
color: var(--text-primary);
|
color: var(--primary-dark);
|
||||||
font-size: 1rem;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.usage-section p {
|
.usage-section p {
|
||||||
color: var(--text-secondary);
|
color: var(--text-light);
|
||||||
margin-bottom: 12px;
|
margin-bottom: 0.5rem;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.usage-section pre {
|
.usage-section pre {
|
||||||
background: #0d0d0f;
|
background-color: #1e1e1e;
|
||||||
border: 1px solid var(--border-primary);
|
color: #d4d4d4;
|
||||||
padding: 16px 20px;
|
padding: 1rem;
|
||||||
border-radius: var(--radius-md);
|
border-radius: 6px;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.usage-section code {
|
.usage-section code {
|
||||||
font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
|
font-family: 'Fira Code', 'Consolas', monospace;
|
||||||
font-size: 0.8125rem;
|
font-size: 0.875rem;
|
||||||
color: #e2e8f0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Syntax highlighting for code blocks */
|
|
||||||
.usage-section pre {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.usage-section pre::before {
|
|
||||||
content: 'bash';
|
|
||||||
position: absolute;
|
|
||||||
top: 8px;
|
|
||||||
right: 12px;
|
|
||||||
font-size: 0.6875rem;
|
|
||||||
color: var(--text-muted);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.05em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy button for code blocks (optional enhancement) */
|
|
||||||
.code-block {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.code-block .copy-btn {
|
|
||||||
position: absolute;
|
|
||||||
top: 8px;
|
|
||||||
right: 8px;
|
|
||||||
background: var(--bg-tertiary);
|
|
||||||
border: 1px solid var(--border-primary);
|
|
||||||
color: var(--text-secondary);
|
|
||||||
padding: 4px 8px;
|
|
||||||
border-radius: var(--radius-sm);
|
|
||||||
font-size: 0.6875rem;
|
|
||||||
cursor: pointer;
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity var(--transition-fast);
|
|
||||||
}
|
|
||||||
|
|
||||||
.code-block:hover .copy-btn {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.code-block .copy-btn:hover {
|
|
||||||
background: var(--bg-hover);
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Responsive adjustments */
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.upload-form {
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: stretch;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload-form .form-group {
|
|
||||||
min-width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tags-table {
|
|
||||||
overflow-x: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tags-table table {
|
|
||||||
min-width: 500px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user