mirror of
https://codeberg.org/icewind/originfox.git
synced 2026-06-03 18:24:07 +02:00
handle files with no referrer
This commit is contained in:
parent
bf5db4932d
commit
3c393a5f5e
1 changed files with 8 additions and 12 deletions
20
src/main.rs
20
src/main.rs
|
|
@ -81,8 +81,8 @@ fn help() {
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct Packet {
|
struct Packet {
|
||||||
path: String,
|
path: String,
|
||||||
origin: String,
|
origin: Option<String>,
|
||||||
referrer: String,
|
referrer: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
|
|
@ -91,16 +91,12 @@ struct Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_attr(packet: Packet) -> Result<(), IoError> {
|
fn set_attr(packet: Packet) -> Result<(), IoError> {
|
||||||
xattr::set(
|
if let Some(origin) = packet.origin {
|
||||||
&packet.path,
|
xattr::set(&packet.path, "user.xdg.origin.url", origin.as_bytes())?;
|
||||||
"user.xdg.origin.url",
|
}
|
||||||
packet.origin.as_bytes(),
|
if let Some(referrer) = packet.referrer {
|
||||||
)?;
|
xattr::set(&packet.path, "user.xdg.referrer.url", referrer.as_bytes())?;
|
||||||
xattr::set(
|
}
|
||||||
&packet.path,
|
|
||||||
"user.xdg.referrer.url",
|
|
||||||
packet.referrer.as_bytes(),
|
|
||||||
)?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue