Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-Dwarnings"

jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --all --check
working-directory: src-tauri

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev
- run: cargo clippy --workspace --all-targets -- -D warnings
working-directory: src-tauri

test:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev
- run: cargo test --workspace
working-directory: src-tauri

frontend:
name: Frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun install
- run: bun run build
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release

on:
push:
tags:
- "v*"
workflow_dispatch:

permissions:
contents: write

jobs:
build:
name: Build (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: aarch64-apple-darwin
- os: macos-13
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri

- uses: oven-sh/setup-bun@v2

- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev

- run: bun install

- name: Run tests
working-directory: src-tauri
run: cargo test --workspace

- name: Build Tauri app
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: ${{ github.ref_name }}
releaseName: "RBitt ${{ github.ref_name }}"
releaseBody: "See the assets below to download and install RBitt."
releaseDraft: true
prerelease: false
2 changes: 1 addition & 1 deletion examples/generate_torrents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn generate_v1_single_file(dir: &Path) {
fn generate_v1_multi_file(dir: &Path) {
let piece_length: i64 = 16384;

let files = vec![
let files = [
(b"file1.txt".to_vec(), 512i64),
(b"file2.txt".to_vec(), 768i64),
(b"subdir/file3.txt".to_vec(), 256i64),
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/crates/oxidebt-cache/src/block_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl PieceBlocks {

fn assemble(&self) -> Bytes {
let mut data = Vec::with_capacity(self.piece_length as usize);
for (_, block) in &self.blocks {
for block in self.blocks.values() {
data.extend_from_slice(block);
}
Bytes::from(data)
Expand Down
3 changes: 3 additions & 0 deletions src-tauri/crates/oxidebt-cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ pub use block_cache::{BlockCache, HashState};
pub use buffer_pool::BufferPool;
pub use memory_budget::{MemoryBudget, MemoryPermit};
pub use piece_cache::PieceCache;

#[cfg(test)]
mod tests;
6 changes: 2 additions & 4 deletions src-tauri/crates/oxidebt-cache/src/piece_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,8 @@ impl PieceCache {
if t1_len < self.capacity {
self.b1.write().pop_front();
self.replace(&key, false);
} else {
if let Some((_, _, size)) = self.t1.write().pop_front() {
self.memory_used.fetch_sub(size, Ordering::Relaxed);
}
} else if let Some((_, _, size)) = self.t1.write().pop_front() {
self.memory_used.fetch_sub(size, Ordering::Relaxed);
}
} else {
let total = t1_len + b1_len + self.t2.read().len() + self.b2.read().len();
Expand Down
Loading
Loading