mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Minor changes
This commit is contained in:
parent
0a93a4e9a4
commit
e0077f6a10
5 changed files with 33 additions and 33 deletions
2
.github/ISSUE_TEMPLATE/bug.yml
vendored
2
.github/ISSUE_TEMPLATE/bug.yml
vendored
|
|
@ -25,7 +25,7 @@ body:
|
|||
- type: dropdown
|
||||
id: tried_main
|
||||
attributes:
|
||||
label: Did you try the latest main branch to see if the problem got fixed?
|
||||
label: Did you try the latest code to see if this problem got fixed?
|
||||
options:
|
||||
- Tried, but the problem still
|
||||
- Not tried, and I'll explain why below
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ pub enum Body<'a> {
|
|||
Bulk(BodyBulk<'a>),
|
||||
Yank(BodyYank<'a>),
|
||||
Move(BodyMove<'a>),
|
||||
Delete(BodyDelete<'a>),
|
||||
Trash(BodyTrash<'a>),
|
||||
Delete(BodyDelete<'a>),
|
||||
Custom(BodyCustom),
|
||||
}
|
||||
|
||||
|
|
@ -32,8 +32,8 @@ impl<'a> Body<'a> {
|
|||
"bulk" => Body::Bulk(serde_json::from_str(body)?),
|
||||
"yank" => Body::Yank(serde_json::from_str(body)?),
|
||||
"move" => Body::Move(serde_json::from_str(body)?),
|
||||
"delete" => Body::Delete(serde_json::from_str(body)?),
|
||||
"trash" => Body::Trash(serde_json::from_str(body)?),
|
||||
"delete" => Body::Delete(serde_json::from_str(body)?),
|
||||
_ => BodyCustom::from_str(kind, body)?,
|
||||
})
|
||||
}
|
||||
|
|
@ -61,8 +61,8 @@ impl<'a> Body<'a> {
|
|||
Self::Bulk(_) => "bulk",
|
||||
Self::Yank(_) => "yank",
|
||||
Body::Move(_) => "move",
|
||||
Body::Delete(_) => "delete",
|
||||
Body::Trash(_) => "trash",
|
||||
Body::Delete(_) => "delete",
|
||||
Self::Custom(b) => b.kind.as_str(),
|
||||
}
|
||||
}
|
||||
|
|
@ -104,8 +104,8 @@ impl IntoLua<'_> for Body<'static> {
|
|||
Body::Bulk(b) => b.into_lua(lua),
|
||||
Body::Yank(b) => b.into_lua(lua),
|
||||
Body::Move(b) => b.into_lua(lua),
|
||||
Body::Delete(b) => b.into_lua(lua),
|
||||
Body::Trash(b) => b.into_lua(lua),
|
||||
Body::Delete(b) => b.into_lua(lua),
|
||||
Body::Custom(b) => b.into_lua(lua),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,8 +85,8 @@ impl Display for Payload<'_> {
|
|||
Body::Bulk(b) => serde_json::to_string(b),
|
||||
Body::Yank(b) => serde_json::to_string(b),
|
||||
Body::Move(b) => serde_json::to_string(b),
|
||||
Body::Delete(b) => serde_json::to_string(b),
|
||||
Body::Trash(b) => serde_json::to_string(b),
|
||||
Body::Delete(b) => serde_json::to_string(b),
|
||||
Body::Custom(b) => serde_json::to_string(b),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -155,18 +155,6 @@ impl Pubsub {
|
|||
}
|
||||
}
|
||||
|
||||
pub(super) fn pub_from_delete(urls: Vec<Url>) {
|
||||
if PEERS.read().values().any(|p| p.able("delete")) {
|
||||
Client::push(BodyDelete::borrowed(&urls));
|
||||
}
|
||||
if BOOT.local_events.contains("delete") {
|
||||
BodyDelete::borrowed(&urls).with_receiver(*ID).flush();
|
||||
}
|
||||
if LOCAL.read().contains_key("delete") {
|
||||
Self::pub_(BodyDelete::owned(urls));
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn pub_from_trash(urls: Vec<Url>) {
|
||||
if PEERS.read().values().any(|p| p.able("trash")) {
|
||||
Client::push(BodyTrash::borrowed(&urls));
|
||||
|
|
@ -178,4 +166,16 @@ impl Pubsub {
|
|||
Self::pub_(BodyTrash::owned(urls));
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn pub_from_delete(urls: Vec<Url>) {
|
||||
if PEERS.read().values().any(|p| p.able("delete")) {
|
||||
Client::push(BodyDelete::borrowed(&urls));
|
||||
}
|
||||
if BOOT.local_events.contains("delete") {
|
||||
BodyDelete::borrowed(&urls).with_receiver(*ID).flush();
|
||||
}
|
||||
if LOCAL.read().contains_key("delete") {
|
||||
Self::pub_(BodyDelete::owned(urls));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ use crate::{body::BodyMoveItem, Pubsub};
|
|||
|
||||
static CT: RoCell<CancellationToken> = RoCell::new();
|
||||
static MOVE_TX: Mutex<Option<mpsc::UnboundedSender<BodyMoveItem>>> = Mutex::new(None);
|
||||
static DELETE_TX: Mutex<Option<mpsc::UnboundedSender<Url>>> = Mutex::new(None);
|
||||
static TRASH_TX: Mutex<Option<mpsc::UnboundedSender<Url>>> = Mutex::new(None);
|
||||
static DELETE_TX: Mutex<Option<mpsc::UnboundedSender<Url>>> = Mutex::new(None);
|
||||
|
||||
pub struct Pump;
|
||||
|
||||
|
|
@ -23,13 +23,6 @@ impl Pump {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn push_delete(target: Url) {
|
||||
if let Some(tx) = &*DELETE_TX.lock() {
|
||||
tx.send(target).ok();
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn push_trash(target: Url) {
|
||||
if let Some(tx) = &*TRASH_TX.lock() {
|
||||
|
|
@ -37,33 +30,40 @@ impl Pump {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn push_delete(target: Url) {
|
||||
if let Some(tx) = &*DELETE_TX.lock() {
|
||||
tx.send(target).ok();
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn serve() {
|
||||
let (move_tx, move_rx) = mpsc::unbounded_channel();
|
||||
let (delete_tx, delete_rx) = mpsc::unbounded_channel();
|
||||
let (trash_tx, trash_rx) = mpsc::unbounded_channel();
|
||||
let (delete_tx, delete_rx) = mpsc::unbounded_channel();
|
||||
|
||||
CT.with(Default::default);
|
||||
MOVE_TX.lock().replace(move_tx);
|
||||
DELETE_TX.lock().replace(delete_tx);
|
||||
TRASH_TX.lock().replace(trash_tx);
|
||||
DELETE_TX.lock().replace(delete_tx);
|
||||
|
||||
tokio::spawn(async move {
|
||||
let move_rx =
|
||||
UnboundedReceiverStream::new(move_rx).chunks_timeout(1000, Duration::from_millis(500));
|
||||
let delete_rx =
|
||||
UnboundedReceiverStream::new(delete_rx).chunks_timeout(1000, Duration::from_millis(500));
|
||||
let trash_rx =
|
||||
UnboundedReceiverStream::new(trash_rx).chunks_timeout(1000, Duration::from_millis(500));
|
||||
let delete_rx =
|
||||
UnboundedReceiverStream::new(delete_rx).chunks_timeout(1000, Duration::from_millis(500));
|
||||
|
||||
pin!(move_rx);
|
||||
pin!(delete_rx);
|
||||
pin!(trash_rx);
|
||||
pin!(delete_rx);
|
||||
|
||||
loop {
|
||||
select! {
|
||||
Some(items) = move_rx.next() => Pubsub::pub_from_move(items),
|
||||
Some(urls) = trash_rx.next() => Pubsub::pub_from_trash(urls),
|
||||
Some(urls) = delete_rx.next() => Pubsub::pub_from_delete(urls),
|
||||
Some(urls) = trash_rx.next() => Pubsub::pub_from_trash(urls),
|
||||
else => {
|
||||
CT.cancel();
|
||||
break;
|
||||
|
|
@ -75,8 +75,8 @@ impl Pump {
|
|||
|
||||
pub(super) async fn shutdown() {
|
||||
drop(MOVE_TX.lock().take());
|
||||
drop(DELETE_TX.lock().take());
|
||||
drop(TRASH_TX.lock().take());
|
||||
drop(DELETE_TX.lock().take());
|
||||
CT.cancelled().await;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue