screenshot: Use separate error when disk writes are locked down

The most likely reason for rejecting a screenshot request is that
there's an ongoing operation from the same sender. Still, we shouldn't
assume that that is the case and return an appropriate error when
writing to disk is disabled via lockdown settings.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3618

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1589>
This commit is contained in:
Florian Müllner 2021-01-25 12:38:51 +01:00 committed by Marge Bot
parent c853de20eb
commit 1aee0516d6

View File

@ -36,11 +36,16 @@ var ScreenshotService = class {
lockedDown = this._lockdownSettings.get_boolean('disable-save-to-disk');
let sender = invocation.get_sender();
if (this._screenShooter.has(sender) || lockedDown) {
if (this._screenShooter.has(sender)) {
invocation.return_error_literal(
Gio.IOErrorEnum, Gio.IOErrorEnum.BUSY,
'There is an ongoing operation for this sender');
return null;
} else if (lockedDown) {
invocation.return_error_literal(
Gio.IOErrorEnum, Gio.IOErrorEnum.PERMISSION_DENIED,
'Saving to disk is disabled');
return null;
}
let shooter = new Shell.Screenshot();