1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

ox: expand file and check for existance before trying to announce

Output before:
```
11:00:00 - Annonuce OpenPGP Key for OX ~/test/testuser.pub.gpg ...
```

After:
```
11:00:00 - Annonuce OpenPGP Key for OX /home/user/test/testuser.pub.gpg ...
```

Now we expand the path so that we can check for `~` properly.
And test if the file is actually a normal file.
This commit is contained in:
Michael Vetter 2022-02-24 11:57:25 +01:00
parent 8173878bc7
commit 6d17b36605

View File

@ -7613,7 +7613,22 @@ cmd_ox(ProfWin* window, const char* const command, gchar** args)
return TRUE; return TRUE;
} else if (g_strcmp0(args[0], "announce") == 0) { } else if (g_strcmp0(args[0], "announce") == 0) {
if (args[1]) { if (args[1]) {
ox_announce_public_key(args[1]); gchar* filename = get_expanded_path(args[1]);
if (access(filename, R_OK) != 0) {
cons_show_error("File not found: %s", filename);
g_free(filename);
return TRUE;
}
if (!is_regular_file(filename)) {
cons_show_error("Not a file: %s", filename);
g_free(filename);
return TRUE;
}
ox_announce_public_key(filename);
free(filename);
} else { } else {
cons_show("Filename is required"); cons_show("Filename is required");
} }