Skip to content

Commit 672bfe3

Browse files
committed
Fix lints and remove more dead code.
1 parent a3f7609 commit 672bfe3

File tree

9 files changed

+30
-575
lines changed

9 files changed

+30
-575
lines changed

src/backend.rs

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ pub(crate) mod sqlite;
55
use crate::protos::Item;
66
use core::str::FromStr;
77
use std::{fmt::Display, io::{Read, Seek, SeekFrom}, marker::PhantomData};
8-
use actix_web::{web::Bytes};
9-
use anyhow::{Error, Context, bail, format_err};
8+
use actix_web::web::Bytes;
9+
use anyhow::{Error, bail, format_err};
1010
use bs58;
1111
use futures::Stream;
1212
use serde::{Deserialize, de::{self, Visitor}};
@@ -349,6 +349,7 @@ pub struct ItemDisplayRow {
349349
// TODO: Make an Arc<String> to avoid heap allocs?
350350
// Or just make filling this in optional, since that's only used by the old HTML UI.
351351
/// The display name for the author of the item, if available.
352+
#[allow(dead_code)]
352353
pub display_name: Option<String>
353354
}
354355

@@ -375,18 +376,6 @@ impl Timestamp {
375376
unix_utc_ms: delta.whole_milliseconds() as i64,
376377
}
377378
}
378-
379-
pub fn format_with_offset(self, minutes: i16) -> String {
380-
use time::{Duration, UtcOffset, OffsetDateTime};
381-
use std::ops::Add;
382-
383-
let ms = Duration::milliseconds(self.unix_utc_ms);
384-
let datetime = OffsetDateTime::unix_epoch().add(ms);
385-
let offset = UtcOffset::minutes(minutes);
386-
let datetime = datetime.to_offset(offset);
387-
388-
datetime.format("%Y-%m-%d %H:%M:%S %z")
389-
}
390379
}
391380
/// A reason why a user can't post an Item or file attachment.
392381
pub enum QuotaDenyReason {
@@ -403,6 +392,7 @@ pub enum QuotaDenyReason {
403392
UnknownUser,
404393

405394
/// We already have a profile that proves that this userID has been revoked.
395+
#[allow(dead_code)]
406396
ProfileRevoked,
407397
}
408398

@@ -451,11 +441,9 @@ impl SHA512 {
451441
file.seek(SeekFrom::Start(0))?;
452442
let mut buf = [0u8; 8 * 1024];
453443
let mut hasher = sha512::State::new();
454-
let mut bytes = 0;
455444
loop {
456445
let count = file.read(&mut buf)?;
457446
if count == 0 { break; }
458-
bytes += count;
459447
hasher.update(&buf[..count]);
460448
}
461449

@@ -494,10 +482,6 @@ impl TimeSpan {
494482
}
495483
}
496484

497-
pub struct UsageByUserOpts {
498-
499-
}
500-
501485
pub struct PruneOpts {
502486
/// If set, then we don't actually do the delete and just report on what *would* be deleted.
503487
pub dry_run: bool,
@@ -528,7 +512,7 @@ pub struct PruneResult {
528512

529513
impl Display for PruneResult {
530514
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
531-
use tablestream::{Stream, col, Column};
515+
use tablestream::{Stream, col};
532516

533517
let title = if self.dry_run { "Dry run:" } else { "Pruned:" };
534518

@@ -549,22 +533,23 @@ impl Display for PruneResult {
549533
name: "Attachments",
550534
count: self.attachments_count,
551535
size: SizeDisplay::bytes(self.attachments_bytes),
552-
}).map_err(|e| std::fmt::Error)?;
536+
}).map_err(|_| std::fmt::Error)?;
553537

554538
stream.row(Row{
555539
name: "Items",
556540
count: self.items_count,
557541
size: SizeDisplay::bytes(self.items_count)
558-
}).map_err(|e| std::fmt::Error)?;
542+
}).map_err(|_| std::fmt::Error)?;
559543

560544
let footer = format!("Total size: {}", SizeDisplay::bytes(self.items_bytes + self.attachments_bytes));
561-
stream.footer(&footer).map_err(|e| std::fmt::Error)?;
545+
stream.footer(&footer).map_err(|_| std::fmt::Error)?;
562546

563547
write!(f, "{}", String::from_utf8_lossy(&out))
564548
}
565549
}
566550

567551
/// Information about a single user's database usage.
552+
#[allow(dead_code)]
568553
pub struct UsageByUserRow {
569554
pub user_id: UserID,
570555
pub display_name: Option<String>,

src/backend/sqlite.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99

1010
mod upgraders;
1111

12-
use std::{io::{Read, Write}, ops::DerefMut, path::Path, collections::HashMap};
12+
use std::{io::{Read, Write}, path::Path, collections::HashMap};
1313

1414
use crate::{backend::UsageByUserRow, protos::Item, util::AsHex};
1515
use actix_web::web::Bytes;
1616
use backend::{FileMeta, RowCallback, SHA512};
17-
use futures::Stream;
1817
use log::{debug, warn};
1918
use r2d2_sqlite::SqliteConnectionManager;
2019
use rusqlite::{DatabaseName, NO_PARAMS, OpenFlags, named_params};
@@ -211,9 +210,6 @@ pub(crate) struct Connection
211210
pool: Pool,
212211
}
213212

214-
trait SqliteConn: DerefMut<Target=rusqlite::Connection> {}
215-
impl <T: DerefMut<Target=rusqlite::Connection>> SqliteConn for T {}
216-
217213

218214
/// private methods for Conneciton
219215
impl Connection

src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
#![cfg_attr(debug_assertions, allow(dead_code, unused_imports, unused_variables))]
21
#![deny(unknown_lints)]
32
#![deny(unused_must_use)]
43

54
#[cfg(test)]
65
mod tests;
76

8-
use crate::{backend::{Factory, PruneOpts, ServerUser, UsageByUserRow, UserID, sqlite}, util::AsHex};
7+
use crate::{backend::{PruneOpts, ServerUser, UserID, sqlite}, util::AsHex};
98
use anyhow::{Error, bail};
109
use sizedisplay::SizeDisplay;
1110
use structopt::StructOpt;
1211
use tablestream::{Stream, Column, col};
1312

1413
mod backend;
15-
mod markdown;
1614
mod protos;
1715
mod server;
1816
mod util;
@@ -175,7 +173,9 @@ struct UserRemoveCommand {
175173

176174
impl UserRemoveCommand {
177175
fn main(&self) -> Result<(), Error> {
178-
todo!();
176+
let opts = &self.shared_options;
177+
let uid = &self.user_id;
178+
todo!("implement remove user {opts:?} {uid}");
179179
}
180180
}
181181

0 commit comments

Comments
 (0)