Compare commits

...

1 commit

Author SHA1 Message Date
Joe Ardent
e29295246f broken modules 2025-08-14 17:11:01 -07:00
11 changed files with 70 additions and 29 deletions

2
Cargo.lock generated
View file

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

View file

@ -1,6 +1,8 @@
[package]
name = "jocalsend"
version = "1.0.0"
# 1.61803398874989484
#----^
version = "1.6.1"
edition = "2024"
authors = ["Joe Ardent <code@ardent.nebcorp.com>"]
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 futures::{FutureExt, StreamExt};
use jocalsend::{JocalEvent, JocalService, ReceiveDialog, ReceiveRequest, error::Result};
use julid::Julid;
use log::{LevelFilter, debug, error, warn};
use ratatui::{
@ -18,6 +17,8 @@ use simsearch::{SearchOptions, SimSearch};
use tokio::sync::mpsc::UnboundedReceiver;
use tui_input::{Input, backend::crossterm::EventHandler};
use crate::jocalsend::{JocalEvent, JocalService, ReceiveDialog, ReceiveRequest, error::Result};
pub mod widgets;
#[derive(Debug, Clone, PartialEq, Eq)]

View file

@ -12,8 +12,8 @@ use local_ip_address::local_ip;
use serde::{Deserialize, Deserializer, Serialize};
use crate::{
DEFAULT_PORT, MULTICAST_IP,
error::{LocalSendError, Result},
error::{JocalError, Result},
jocalsend::{DEFAULT_PORT, MULTICAST_IP},
models::Device,
};
@ -41,7 +41,7 @@ impl Default for Config {
impl Config {
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 config_file = dirs.config_dir().join("jocalsend.toml");

View file

@ -1,5 +1,5 @@
#[derive(Debug, thiserror::Error)]
pub enum LocalSendError {
pub enum JocalError {
#[error("IO error: {0}")]
IOError(#[from] std::io::Error),
@ -64,4 +64,4 @@ pub enum LocalSendError {
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::{
collections::BTreeMap,
fmt::Debug,
@ -14,10 +7,8 @@ use std::{
time::Duration,
};
pub use config::Config;
use julid::Julid;
use log::error;
use models::{Device, FileMetadata};
use tokio::{
net::UdpSocket,
sync::{
@ -26,7 +17,12 @@ use tokio::{
},
task::JoinSet,
};
use transfer::Session;
use crate::{
config::Config,
models::{Device, FileMetadata},
transfer::Session,
};
pub const DEFAULT_PORT: u16 = 53317;
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 clap::Parser;
use jocalsend::{Config, DEFAULT_INTERVAL, JocalService, JocalTasks, error::Result};
use log::{error, info};
use ratatui::DefaultTerminal;
use ratatui_explorer::FileExplorer;
@ -14,6 +13,16 @@ use app::{App, CurrentScreen, Peer};
mod 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<()> {
// just in case we need to display the help
let _ = Cli::parse();

View file

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

View file

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