Skip to content

Commit

Permalink
release: airup v0.10.4
Browse files Browse the repository at this point in the history
This release contains bug fixes. See CHANGELOG for details.
  • Loading branch information
sisungo committed Jun 21, 2024
1 parent a3e6722 commit 1c7024f
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 21 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Changes in v0.10.4:
* fix: line pipers loses lines when receiving multi lines in one `read`

Changes in v0.10.3:
* fix: line pipers (used for stdio logging) removes `\n`, `\r` or `\0` which is placed on the end of a line
* BREAKING: make `system.refresh` return `[(string, error)]` instead of `null`
Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

## Supported Versions
The `HEAD` and the latest release are supported by the Airup developers. The maintained versions are:
- Mainline: `0.10.3`
- Stable: `0.10.3`
- Mainline: `0.10.4`
- Stable: `0.10.4`

## Reporting a Vulnerability
Please [contact @sisungo](mailto:[email protected]) to report a vulnerability.
2 changes: 1 addition & 1 deletion airup-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ authors = ["sisungo <[email protected]>"]
description = "SDK library of Airup"
documentation = "https://docs.rs/airup-sdk"
repository = "https://github.com/sisungo/airup"
version = "0.10.3"
version = "0.10.4"
edition = "2021"
license = "MIT"

Expand Down
2 changes: 1 addition & 1 deletion airup/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "airup"
authors = ["sisungo <[email protected]>"]
version = "0.10.3"
version = "0.10.4"
edition = "2021"
license = "MIT"
publish = false
Expand Down
2 changes: 1 addition & 1 deletion airupd/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "airupd"
authors = ["sisungo <[email protected]>"]
version = "0.10.3"
version = "0.10.4"
edition = "2021"
license = "MIT"
publish = false
Expand Down
2 changes: 1 addition & 1 deletion airupfx/airupfx-extensions/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "airupfx-extensions"
authors = ["sisungo <[email protected]>"]
version = "0.10.0-rc.1"
version = "0.10.4"
edition = "2021"
license = "MIT"
publish = false
Expand Down
2 changes: 1 addition & 1 deletion airupfx/airupfx-io/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "airupfx-io"
authors = ["sisungo <[email protected]>"]
version = "0.8.2"
version = "0.10.4"
edition = "2021"
license = "MIT"
publish = false
Expand Down
20 changes: 19 additions & 1 deletion airupfx/airupfx-io/src/line_piper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ struct LinePiperEntity<R> {
callback: Box<dyn Callback>,
}
impl<R: AsyncRead + Unpin + Send + 'static> LinePiperEntity<R> {
const LINE_BREAK_BYTES: &'static [u8] = b"\n\r";

fn new(reader: R, callback: Box<dyn Callback>) -> Self {
Self { reader, callback }
}
Expand All @@ -64,7 +66,10 @@ impl<R: AsyncRead + Unpin + Send + 'static> LinePiperEntity<R> {
return None;
}
position += count;
if let Some(pos) = &buf[..position].iter().position(|x| b"\n\r\0".contains(x)) {
if let Some(pos) = &buf[..position]
.iter()
.rposition(|x| Self::LINE_BREAK_BYTES.contains(x))
{
break pos + 1;
}
assert!(position <= 4096);
Expand Down Expand Up @@ -98,3 +103,16 @@ impl Callback for ChannelCallback {
})
}
}

#[cfg(test)]
mod tests {
use super::*;

#[tokio::test]
async fn multi_line() {
const TEST_STRING: &'static [u8] = b"AirupFX Test\nairupfx::io::line_piper\n";

let line_piper = LinePiper::new(TEST_STRING);
assert_eq!(line_piper.read_line().await.unwrap(), TEST_STRING);
}
}
34 changes: 21 additions & 13 deletions extensions/fallback-logger/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,28 @@ async fn append(subject: String, module: String, msg: Vec<u8>) -> Result<(), Err
message: x.to_string(),
})?;
let timestamp = airupfx::time::timestamp_ms();
let mut evaluted_bytes = 0;

let record = LogRecord {
timestamp,
module: module.to_owned(),
message: String::from_utf8_lossy(&msg).into_owned(),
};
writeln!(
appender,
"{}",
serde_json::to_string(&record).unwrap().as_str()
)
.map_err(|x| airup_sdk::Error::Io {
message: x.to_string(),
})?;
for line in msg.split(|x| b"\n\r".contains(x)) {
evaluted_bytes += line.len() + 1;
if evaluted_bytes >= msg.len() && line.is_empty() {
break;
}

let record = LogRecord {
timestamp,
module: module.to_owned(),
message: String::from_utf8_lossy(line).into_owned(),
};
writeln!(
appender,
"{}",
serde_json::to_string(&record).unwrap().as_str()
)
.map_err(|x| airup_sdk::Error::Io {
message: x.to_string(),
})?;
}

Ok(())
}
Expand Down

0 comments on commit 1c7024f

Please sign in to comment.