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
4 changes: 2 additions & 2 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
FROM docker.io/library/rust:trixie AS chef
WORKDIR /tmp
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
RUN cargo binstall --no-confirm cargo-chef cargo-nextest
RUN cargo binstall --no-confirm --locked cargo-chef cargo-nextest

## Tester Image
FROM docker.io/library/rust:slim-trixie AS tester
Expand All @@ -16,7 +16,7 @@ RUN apt-get update \
&& apt-get install -y curl sqlite3 time \
&& apt-get autoclean
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
RUN cargo binstall --no-confirm cargo-nextest
RUN cargo binstall --no-confirm --locked cargo-nextest
# Database initialization: Tests at runtime require a pre-initialized SQLite3 database
# to test against a valid (not corrupted) schema. The VACUUM command optimizes the
# database file layout. This image layer is inherited by test_debug and test stages.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,22 @@ where
}
}

async fn get(&self, key: &InfoHash) -> Option<EntryMutexTokio> {
fn get(&self, key: &InfoHash) -> impl Future<Output = Option<EntryMutexTokio>> + Send {
let db = self.get_torrents();
db.get(key).cloned()
std::future::ready(db.get(key).cloned())
}

async fn get_paginated(&self, pagination: Option<&Pagination>) -> Vec<(InfoHash, EntryMutexTokio)> {
fn get_paginated(&self, pagination: Option<&Pagination>) -> impl Future<Output = Vec<(InfoHash, EntryMutexTokio)>> + Send {
let db = self.get_torrents();

match pagination {
std::future::ready(match pagination {
Some(pagination) => db
.iter()
.skip(pagination.offset as usize)
.take(pagination.limit as usize)
.map(|(a, b)| (*a, b.clone()))
.collect(),
None => db.iter().map(|(a, b)| (*a, b.clone())).collect(),
}
})
}

async fn get_metrics(&self) -> AggregateActiveSwarmMetadata {
Expand All @@ -102,7 +101,7 @@ where
metrics
}

async fn import_persistent(&self, persistent_torrents: &NumberOfDownloadsBTreeMap) {
fn import_persistent(&self, persistent_torrents: &NumberOfDownloadsBTreeMap) -> impl Future<Output = ()> + Send {
let mut db = self.get_torrents_mut();

for (info_hash, completed) in persistent_torrents {
Expand All @@ -121,11 +120,13 @@ where

db.insert(*info_hash, entry);
}

std::future::ready(())
}

async fn remove(&self, key: &InfoHash) -> Option<EntryMutexTokio> {
fn remove(&self, key: &InfoHash) -> impl Future<Output = Option<EntryMutexTokio>> + Send {
let mut db = self.get_torrents_mut();
db.remove(key)
std::future::ready(db.remove(key))
}

async fn remove_inactive_peers(&self, current_cutoff: DurationSinceUnixEpoch) {
Expand Down
Loading