mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-09-05 22:14:30 +08:00
fix: take correct size in encrypted streams
This commit is contained in:
parent
7fa4a38197
commit
381ea31fc1
4 changed files with 112 additions and 19 deletions
102
CONTRIBUTING.md
Normal file
102
CONTRIBUTING.md
Normal file
|
@ -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
|
21
Makefile
21
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."
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue