pinakes-ui: streamline sidebar design
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I0176fa480e5ba40eea5a39685a4f97896a6a6964
This commit is contained in:
parent
3e14bbe607
commit
278bcaa4b0
25 changed files with 1805 additions and 1686 deletions
|
|
@ -165,13 +165,14 @@ impl PluginLoader {
|
|||
// Check content-length header before downloading
|
||||
const MAX_PLUGIN_SIZE: u64 = 100 * 1024 * 1024; // 100 MB
|
||||
if let Some(content_length) = response.content_length()
|
||||
&& content_length > MAX_PLUGIN_SIZE {
|
||||
return Err(anyhow!(
|
||||
"Plugin archive too large: {} bytes (max {} bytes)",
|
||||
content_length,
|
||||
MAX_PLUGIN_SIZE
|
||||
));
|
||||
}
|
||||
&& content_length > MAX_PLUGIN_SIZE
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"Plugin archive too large: {} bytes (max {} bytes)",
|
||||
content_length,
|
||||
MAX_PLUGIN_SIZE
|
||||
));
|
||||
}
|
||||
|
||||
let bytes = response
|
||||
.bytes()
|
||||
|
|
|
|||
|
|
@ -106,26 +106,26 @@ impl WasmPlugin {
|
|||
// If there are params and memory is available, write them
|
||||
let mut alloc_offset: i32 = 0;
|
||||
if !params.is_empty()
|
||||
&& let Some(mem) = &memory {
|
||||
// Call the plugin's alloc function if available, otherwise write at offset 0
|
||||
let offset = if let Ok(alloc) =
|
||||
instance.get_typed_func::<i32, i32>(&mut store, "alloc")
|
||||
{
|
||||
let result = alloc.call_async(&mut store, params.len() as i32).await?;
|
||||
if result < 0 {
|
||||
return Err(anyhow!("plugin alloc returned negative offset: {}", result));
|
||||
}
|
||||
result as usize
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
alloc_offset = offset as i32;
|
||||
let mem_data = mem.data_mut(&mut store);
|
||||
if offset + params.len() <= mem_data.len() {
|
||||
mem_data[offset..offset + params.len()].copy_from_slice(params);
|
||||
&& let Some(mem) = &memory
|
||||
{
|
||||
// Call the plugin's alloc function if available, otherwise write at offset 0
|
||||
let offset = if let Ok(alloc) = instance.get_typed_func::<i32, i32>(&mut store, "alloc")
|
||||
{
|
||||
let result = alloc.call_async(&mut store, params.len() as i32).await?;
|
||||
if result < 0 {
|
||||
return Err(anyhow!("plugin alloc returned negative offset: {}", result));
|
||||
}
|
||||
result as usize
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
alloc_offset = offset as i32;
|
||||
let mem_data = mem.data_mut(&mut store);
|
||||
if offset + params.len() <= mem_data.len() {
|
||||
mem_data[offset..offset + params.len()].copy_from_slice(params);
|
||||
}
|
||||
}
|
||||
|
||||
// Look up the exported function and call it
|
||||
let func = instance
|
||||
|
|
@ -209,14 +209,15 @@ impl HostFunctions {
|
|||
let start = ptr as usize;
|
||||
let end = start + len as usize;
|
||||
if end <= data.len()
|
||||
&& let Ok(msg) = std::str::from_utf8(&data[start..end]) {
|
||||
match level {
|
||||
0 => tracing::error!(plugin = true, "{}", msg),
|
||||
1 => tracing::warn!(plugin = true, "{}", msg),
|
||||
2 => tracing::info!(plugin = true, "{}", msg),
|
||||
_ => tracing::debug!(plugin = true, "{}", msg),
|
||||
}
|
||||
&& let Ok(msg) = std::str::from_utf8(&data[start..end])
|
||||
{
|
||||
match level {
|
||||
0 => tracing::error!(plugin = true, "{}", msg),
|
||||
1 => tracing::warn!(plugin = true, "{}", msg),
|
||||
2 => tracing::info!(plugin = true, "{}", msg),
|
||||
_ => tracing::debug!(plugin = true, "{}", msg),
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
)?;
|
||||
|
|
@ -258,11 +259,7 @@ impl HostFunctions {
|
|||
.filesystem
|
||||
.read
|
||||
.iter()
|
||||
.any(|allowed| {
|
||||
allowed
|
||||
.canonicalize()
|
||||
.is_ok_and(|a| path.starts_with(a))
|
||||
});
|
||||
.any(|allowed| allowed.canonicalize().is_ok_and(|a| path.starts_with(a)));
|
||||
|
||||
if !can_read {
|
||||
tracing::warn!(path = %path_str, "plugin read access denied");
|
||||
|
|
|
|||
|
|
@ -293,9 +293,10 @@ impl TranscodeService {
|
|||
|
||||
// Clean up cache directory
|
||||
if let Some(path) = cache_path
|
||||
&& let Err(e) = tokio::fs::remove_dir_all(&path).await {
|
||||
tracing::error!("failed to remove transcode cache directory: {}", e);
|
||||
}
|
||||
&& let Err(e) = tokio::fs::remove_dir_all(&path).await
|
||||
{
|
||||
tracing::error!("failed to remove transcode cache directory: {}", e);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -311,9 +312,10 @@ impl TranscodeService {
|
|||
.iter()
|
||||
.filter_map(|(id, sess)| {
|
||||
if let Some(expires) = sess.expires_at
|
||||
&& now > expires {
|
||||
return Some((*id, sess.cache_path.clone()));
|
||||
}
|
||||
&& now > expires
|
||||
{
|
||||
return Some((*id, sess.cache_path.clone()));
|
||||
}
|
||||
None
|
||||
})
|
||||
.collect();
|
||||
|
|
@ -475,21 +477,22 @@ async fn run_ffmpeg(
|
|||
while let Ok(Some(line)) = lines.next_line().await {
|
||||
// FFmpeg progress output: "out_time_us=12345678"
|
||||
if let Some(time_str) = line.strip_prefix("out_time_us=")
|
||||
&& let Ok(us) = time_str.trim().parse::<f64>() {
|
||||
let secs = us / 1_000_000.0;
|
||||
// Calculate progress based on known duration
|
||||
let progress = match duration_secs {
|
||||
Some(dur) if dur > 0.0 => (secs / dur).min(0.99) as f32,
|
||||
_ => {
|
||||
// Duration unknown; don't update progress
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let mut s = sessions.write().await;
|
||||
if let Some(sess) = s.get_mut(&session_id) {
|
||||
sess.progress = progress;
|
||||
&& let Ok(us) = time_str.trim().parse::<f64>()
|
||||
{
|
||||
let secs = us / 1_000_000.0;
|
||||
// Calculate progress based on known duration
|
||||
let progress = match duration_secs {
|
||||
Some(dur) if dur > 0.0 => (secs / dur).min(0.99) as f32,
|
||||
_ => {
|
||||
// Duration unknown; don't update progress
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let mut s = sessions.write().await;
|
||||
if let Some(sess) = s.get_mut(&session_id) {
|
||||
sess.progress = progress;
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue