diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..0a2b1769 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,102 @@ +# Contributing to TelDrive + +This guide will help you get started with contributing to TelDrive. + +## Development Setup + +### Prerequisites + +- Go (1.19 or later) +- Node.js (for semver dependency) +- Git +- Make +- PowerShell (for Windows) or Bash (for Unix-like systems) + +### Initial Setup + +1. Clone the repository: +```bash +git clone https://github.com/tgdrive/teldrive.git +cd teldrive +``` + +2. Install dependencies: +```bash +make deps +``` + +## Building TelDrive + +### Complete Build +To build both frontend and backend: +```bash +make build +``` + +### Frontend Development +The frontend is managed in a separate repository ([teldrive-ui](https://github.com/tgdrive/teldrive-ui)). The main repository pulls the latest frontend release during build. + +To set up the frontend: +```bash +make frontend +``` + +### Backend Development +To build the backend only: +```bash +make backend +``` + +### Running TelDrive +After building, run the application: +```bash +make run +``` + +## Feature Development + +1. Create a new branch for your feature: +```bash +git checkout -b feature/your-feature-name +``` + +2. Generate API Spec: +```bash +make gen +``` + +## Version Management + +We follow semantic versioning (MAJOR.MINOR.PATCH): + +- For bug fixes: +```bash +make patch-version +``` + +- For new features: +```bash +make minor-version +``` + +- For breaking changes: +```bash +make major-version +``` + +## Pull Request Guidelines + +1. **Branch Naming**: + - `feature/` for new features + - `fix/` for bug fixes + - `docs/` for documentation changes + - `refactor/` for code refactoring + +2. **Commit Messages**: + - Use clear, descriptive commit messages + - Reference issues when applicable + +3. **Pull Request Description**: + - Describe the changes made + - Include any relevant issue numbers + - List any breaking changes \ No newline at end of file diff --git a/Makefile b/Makefile index b01884bd..0520caef 100644 --- a/Makefile +++ b/Makefile @@ -10,10 +10,6 @@ APP_NAME := teldrive BUILD_DIR := bin FRONTEND_DIR := ui/dist FRONTEND_ASSET := https://github.com/tgdrive/teldrive-ui/releases/download/latest/teldrive-ui.zip -GIT_TAG := $(shell git tag -l '[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -n 1) -ifeq ($(GIT_TAG),) - GIT_TAG := 1.0.0 -endif GIT_COMMIT := $(shell git rev-parse --short HEAD) GIT_LINK := $(shell git remote get-url origin) MODULE_PATH := $(shell go list -m) @@ -23,7 +19,6 @@ GIT_COMMIT := $(shell git rev-parse --short HEAD) VERSION_PACKAGE := $(MODULE_PATH)/internal/version VERSION := $(GIT_TAG) BINARY_EXTENSION := -BUILD_TIME := ifeq ($(IS_WINDOWS),true) BINARY_EXTENSION := .exe @@ -32,18 +27,14 @@ ifeq ($(IS_WINDOWS),true) MKDIR := powershell -Command "New-Item -ItemType Directory -Force" DOWNLOAD := powershell -Command "Invoke-WebRequest -Uri" UNZIP := powershell -Command "Expand-Archive" + GIT_TAG := $(shell git tag -l '[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | Sort-Object -Descending | Select-Object -First 1) else RM := rm -f RMDIR := rm -rf MKDIR := mkdir -p DOWNLOAD := curl -sLO UNZIP := unzip -q -d -endif - -ifeq ($(IS_WINDOWS),true) - BUILD_TIME := $(shell powershell -Command "(Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ss.fffZ')") -else - BUILD_TIME := $(shell date -u '+%Y-%m-%dT%H:%M:%S.000Z') + GIT_TAG := $(shell git tag -l '[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -n 1) endif .PHONY: all build run clean frontend backend run sync-ui retag patch-version minor-version major-version gen check-semver install-semver @@ -77,12 +68,8 @@ gen: backend: gen @echo "Building backend for $(GOOS)/$(GOARCH)..." - go build -trimpath \ - -ldflags "-s -w \ - -X '$(VERSION_PACKAGE).Version=$(VERSION)' \ - -X '$(VERSION_PACKAGE).CommitSHA=$(GIT_COMMIT)' \ - -extldflags=-static" \ - -o $(BUILD_DIR)/$(APP_NAME)$(BINARY_EXTENSION) + go build -trimpath -ldflags "-s -w -X '$(VERSION_PACKAGE).Version=$(GIT_TAG)' -X '$(VERSION_PACKAGE).CommitSHA=$(GIT_COMMIT)' -extldflags=-static" -o $(BUILD_DIR)/$(APP_NAME)$(BINARY_EXTENSION) + build: frontend backend @echo "Building complete." diff --git a/README.md b/README.md index 2fd35883..fdab02cc 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ By following these guidelines, you contribute to the responsible and effective u ## Contributing -Feel free to contribute to this project if you have any further ideas. +Feel free to contribute to this project.See [CONTRIBUTING.md](CONTRIBUTING.md) for more information. ## Donate diff --git a/internal/reader/reader.go b/internal/reader/reader.go index abe2b6e4..9421e7eb 100644 --- a/internal/reader/reader.go +++ b/internal/reader/reader.go @@ -60,12 +60,16 @@ func NewLinearReader(ctx context.Context, concurrency int, ) (io.ReadCloser, error) { + size := parts[0].Size + if file.Encrypted.Value { + size = parts[0].DecryptedSize + } r := &LinearReader{ ctx: ctx, parts: parts, file: file, remaining: end - start + 1, - ranges: calculatePartByteRanges(start, end, parts[0].Size), + ranges: calculatePartByteRanges(start, end, size), config: config, client: client, concurrency: concurrency,