broken modules

This commit is contained in:
Joe Ardent 2025-08-14 17:11:01 -07:00
parent 7eece474a3
commit e29295246f
11 changed files with 70 additions and 29 deletions

2
Cargo.lock generated
View file

@ -1324,7 +1324,7 @@ dependencies = [
[[package]] [[package]]
name = "jocalsend" name = "jocalsend"
version = "1.0.0" version = "1.6.1"
dependencies = [ dependencies = [
"axum", "axum",
"axum-server", "axum-server",

View file

@ -1,6 +1,8 @@
[package] [package]
name = "jocalsend" name = "jocalsend"
version = "1.0.0" # 1.61803398874989484
#----^
version = "1.6.1"
edition = "2024" edition = "2024"
authors = ["Joe Ardent <code@ardent.nebcorp.com>"] authors = ["Joe Ardent <code@ardent.nebcorp.com>"]
keywords = ["p2p", "localsend", "tui", "linux"] keywords = ["p2p", "localsend", "tui", "linux"]

1
VERSION Normal file
View file

@ -0,0 +1 @@
1.61

32
VERSIONING.md Normal file
View file

@ -0,0 +1,32 @@
# Golden Versioning
This software is versioned under a scheme I call "goldver", as an homage to the
vastly inferior [semver](https://semver.org).
## What does "goldver" mean?
When projects are versioned with goldver, the first version is "1". Note that it
is not "1.0", or, "1.0-prealpha-release-preview", or anything nonsensical like
that. As new versions are released, decimals from *phi*, the [Golden
Ratio](https://en.wikipedia.org/wiki/Golden_ratio), are appended after an
initial decimal point. So the second released version will be "1.6", the third
would be "1.61", etc., and on until perfection is asymptotically approached as
the number of released versions goes to infinity.
## Wait, didn't Donald Knuth do this?
No! He uses [pi for TeX and e for MetaFont](https://texfaq.org/FAQ-TeXfuture),
obviously COMPLETELY different.
## Ok.
Cool.
## What version is Julid now?
Canonically, see the `VERSION` file. Heretically, once there have been
at least three releases, the version string in the `Cargo.toml` file will
always be of the form "1.6.x", where *x* is at least one digit long, starting
with "1". Each subsequent release will append the next digit of *phi* to
*x*. The number of releases can be calculated by counting the number of digits
in *x* and adding 2 to that.

View file

@ -6,7 +6,6 @@ use std::{
use crossterm::event::{Event, EventStream, KeyCode, KeyEvent, KeyEventKind}; use crossterm::event::{Event, EventStream, KeyCode, KeyEvent, KeyEventKind};
use futures::{FutureExt, StreamExt}; use futures::{FutureExt, StreamExt};
use jocalsend::{JocalEvent, JocalService, ReceiveDialog, ReceiveRequest, error::Result};
use julid::Julid; use julid::Julid;
use log::{LevelFilter, debug, error, warn}; use log::{LevelFilter, debug, error, warn};
use ratatui::{ use ratatui::{
@ -18,6 +17,8 @@ use simsearch::{SearchOptions, SimSearch};
use tokio::sync::mpsc::UnboundedReceiver; use tokio::sync::mpsc::UnboundedReceiver;
use tui_input::{Input, backend::crossterm::EventHandler}; use tui_input::{Input, backend::crossterm::EventHandler};
use crate::jocalsend::{JocalEvent, JocalService, ReceiveDialog, ReceiveRequest, error::Result};
pub mod widgets; pub mod widgets;
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]

View file

@ -12,8 +12,8 @@ use local_ip_address::local_ip;
use serde::{Deserialize, Deserializer, Serialize}; use serde::{Deserialize, Deserializer, Serialize};
use crate::{ use crate::{
DEFAULT_PORT, MULTICAST_IP, error::{JocalError, Result},
error::{LocalSendError, Result}, jocalsend::{DEFAULT_PORT, MULTICAST_IP},
models::Device, models::Device,
}; };
@ -41,7 +41,7 @@ impl Default for Config {
impl Config { impl Config {
pub fn new() -> Result<Self> { pub fn new() -> Result<Self> {
let dirs = directories::BaseDirs::new().ok_or(LocalSendError::NoHomeDir)?; let dirs = directories::BaseDirs::new().ok_or(JocalError::NoHomeDir)?;
let download_dir = dirs.home_dir().join("jocalsend-downloads"); let download_dir = dirs.home_dir().join("jocalsend-downloads");
let config_file = dirs.config_dir().join("jocalsend.toml"); let config_file = dirs.config_dir().join("jocalsend.toml");

View file

@ -1,5 +1,5 @@
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum LocalSendError { pub enum JocalError {
#[error("IO error: {0}")] #[error("IO error: {0}")]
IOError(#[from] std::io::Error), IOError(#[from] std::io::Error),
@ -64,4 +64,4 @@ pub enum LocalSendError {
ConfigParseError(#[from] Box<figment::Error>), ConfigParseError(#[from] Box<figment::Error>),
} }
pub type Result<T> = std::result::Result<T, LocalSendError>; pub type Result<T> = std::result::Result<T, JocalError>;

View file

@ -1,10 +1,3 @@
pub mod config;
pub mod discovery;
pub mod error;
pub mod http_server;
pub mod models;
pub mod transfer;
use std::{ use std::{
collections::BTreeMap, collections::BTreeMap,
fmt::Debug, fmt::Debug,
@ -14,10 +7,8 @@ use std::{
time::Duration, time::Duration,
}; };
pub use config::Config;
use julid::Julid; use julid::Julid;
use log::error; use log::error;
use models::{Device, FileMetadata};
use tokio::{ use tokio::{
net::UdpSocket, net::UdpSocket,
sync::{ sync::{
@ -26,7 +17,12 @@ use tokio::{
}, },
task::JoinSet, task::JoinSet,
}; };
use transfer::Session;
use crate::{
config::Config,
models::{Device, FileMetadata},
transfer::Session,
};
pub const DEFAULT_PORT: u16 = 53317; pub const DEFAULT_PORT: u16 = 53317;
pub const MULTICAST_IP: Ipv4Addr = Ipv4Addr::new(224, 0, 0, 167); pub const MULTICAST_IP: Ipv4Addr = Ipv4Addr::new(224, 0, 0, 167);

View file

@ -1,7 +1,6 @@
use std::{path::Path, str::FromStr, time::Duration}; use std::{path::Path, str::FromStr, time::Duration};
use clap::Parser; use clap::Parser;
use jocalsend::{Config, DEFAULT_INTERVAL, JocalService, JocalTasks, error::Result};
use log::{error, info}; use log::{error, info};
use ratatui::DefaultTerminal; use ratatui::DefaultTerminal;
use ratatui_explorer::FileExplorer; use ratatui_explorer::FileExplorer;
@ -14,6 +13,16 @@ use app::{App, CurrentScreen, Peer};
mod cli; mod cli;
use cli::Cli; use cli::Cli;
mod jocalsend;
use jocalsend::{Config, DEFAULT_INTERVAL, JocalService, JocalTasks, error::Result};
mod config;
mod discovery;
mod error;
mod http_server;
mod models;
mod transfer;
fn main() -> Result<()> { fn main() -> Result<()> {
// just in case we need to display the help // just in case we need to display the help
let _ = Cli::parse(); let _ = Cli::parse();

View file

@ -4,7 +4,7 @@ use chrono::{DateTime, Utc};
use julid::Julid; use julid::Julid;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::error::LocalSendError; use crate::error::JocalError;
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
@ -33,7 +33,7 @@ impl FileMetadata {
pub fn from_path(path: &Path) -> crate::error::Result<Self> { pub fn from_path(path: &Path) -> crate::error::Result<Self> {
let metadata = path.metadata()?; let metadata = path.metadata()?;
if !metadata.is_file() { if !metadata.is_file() {
return Err(LocalSendError::NotAFile); return Err(JocalError::NotAFile);
} }
let id = path.to_str().unwrap().to_string(); let id = path.to_str().unwrap().to_string();

View file

@ -15,7 +15,7 @@ use tokio::sync::mpsc::{UnboundedSender, unbounded_channel};
use crate::{ use crate::{
JocalEvent, JocalService, Peers, ReceiveDialog, ReceiveRequest, SendingType, Sessions, JocalEvent, JocalService, Peers, ReceiveDialog, ReceiveRequest, SendingType, Sessions,
error::{LocalSendError, Result}, error::{JocalError, Result},
models::{Device, FileMetadata}, models::{Device, FileMetadata},
}; };
@ -68,7 +68,7 @@ impl JocalService {
let sessions = self.sessions.lock().await; let sessions = self.sessions.lock().await;
let session = sessions let session = sessions
.get(session_id) .get(session_id)
.ok_or(LocalSendError::SessionNotFound)?; .ok_or(JocalError::SessionNotFound)?;
let request = self let request = self
.client .client
@ -80,7 +80,7 @@ impl JocalService {
.await?; .await?;
if request.status() != 200 { if request.status() != 200 {
return Err(LocalSendError::CancelFailed); return Err(JocalError::CancelFailed);
} }
Ok(()) Ok(())
@ -361,11 +361,11 @@ async fn do_send_bytes(
let session = sessions.get(session_id).unwrap(); let session = sessions.get(session_id).unwrap();
if session.status != SessionStatus::Active { if session.status != SessionStatus::Active {
return Err(LocalSendError::SessionInactive); return Err(JocalError::SessionInactive);
} }
if session.file_tokens.get(content_id) != Some(token) { if session.file_tokens.get(content_id) != Some(token) {
return Err(LocalSendError::InvalidToken); return Err(JocalError::InvalidToken);
} }
let request = client let request = client
@ -379,7 +379,7 @@ async fn do_send_bytes(
if response.status() != 200 { if response.status() != 200 {
log::trace!("non-200 remote response: {response:?}"); log::trace!("non-200 remote response: {response:?}");
return Err(LocalSendError::UploadFailed); return Err(JocalError::UploadFailed);
} }
Ok(()) Ok(())
@ -395,7 +395,7 @@ async fn do_prepare_upload(
files: BTreeMap<String, FileMetadata>, files: BTreeMap<String, FileMetadata>,
) -> Result<PrepareUploadResponse> { ) -> Result<PrepareUploadResponse> {
let Some((addr, device)) = peers.lock().await.get(peer).cloned() else { let Some((addr, device)) = peers.lock().await.get(peer).cloned() else {
return Err(LocalSendError::PeerNotFound); return Err(JocalError::PeerNotFound);
}; };
log::debug!("preparing upload request"); log::debug!("preparing upload request");
@ -421,7 +421,7 @@ async fn do_prepare_upload(
let response: PrepareUploadResponse = match response.json().await { let response: PrepareUploadResponse = match response.json().await {
Err(e) => { Err(e) => {
error!("got error deserializing response: {e:?}"); error!("got error deserializing response: {e:?}");
return Err(LocalSendError::RequestError(e)); return Err(JocalError::RequestError(e));
} }
Ok(r) => r, Ok(r) => r,
}; };