Skip to content

Commit

Permalink
fix: take correct size in encrypted streams
Browse files Browse the repository at this point in the history
  • Loading branch information
bhunter234 authored and divyam234 committed Jan 11, 2025
1 parent 7fa4a38 commit 381ea31
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 19 deletions.
102 changes: 102 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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 changes: 4 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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."
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion internal/reader/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 381ea31

Please sign in to comment.