mirror of
https://github.com/lhns/steam-frame-nix.git
synced 2026-10-06 06:00:22 +02:00
Firefox: the desktop profile wrapper keeps prefs.js when rewriting it fails
A failed write of prefs.js.sfn (e.g. a full disk) emptied prefs.js; now prefs.js and the user.js link stay for the next launch to retry.
This commit is contained in:
1 parent
4538ecea06
commit
2e259c49fe
3 files changed
+24
-6
No files matched your search
+3
-2
@@ -81,8 +81,9 @@ profile's `user.js` to `/app/etc/firefox/steam-frame-nix-desktop-user.js`
|
|||||||
(a sandbox path) right before starting Firefox, waits for it, and once it
|
(a sandbox path) right before starting Firefox, waits for it, and once it
|
||||||
has exited and the profile is no longer in use removes the link and the
|
has exited and the profile is no longer in use removes the link and the
|
||||||
value Firefox stored from it in `prefs.js`. A second launch that just hands
|
value Firefox stored from it in `prefs.js`. A second launch that just hands
|
||||||
a URL to the running Firefox leaves both in place. After a crash, the next
|
a URL to the running Firefox leaves both in place. After a crash (or if
|
||||||
launch or `steam-frame-nix-cleanup` (on switch) removes them.
|
`prefs.js` can't be rewritten), the next launch or `steam-frame-nix-cleanup`
|
||||||
|
(on switch) removes them.
|
||||||
|
|
||||||
### Older versions
|
### Older versions
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# Checks of the Firefox wrapper's desktop profile user.js (wrapper.nix)
|
# Checks of the Firefox wrapper's desktop profile user.js (wrapper.nix)
|
||||||
# against a fake flatpak: the link exists only while Firefox runs, a second
|
# against a fake flatpak: the link exists only while Firefox runs, a second
|
||||||
# launch that hands over to the running Firefox doesn't remove it, the value
|
# launch that hands over to the running Firefox doesn't remove it, the value
|
||||||
# Firefox stored from it leaves prefs.js once the profile is unlocked, a
|
# Firefox stored from it leaves prefs.js once the profile is unlocked (not
|
||||||
# user.js of the user's own is never touched, the profile manager action and
|
# lost if prefs.js can't be rewritten), a user.js of the user's own is never
|
||||||
|
# touched, the profile manager action and
|
||||||
# the Steam session get no --profile.
|
# the Steam session get no --profile.
|
||||||
{ pkgs }:
|
{ pkgs }:
|
||||||
let
|
let
|
||||||
@@ -61,6 +62,17 @@ pkgs.runCommand "firefox-check" { nativeBuildInputs = [ pkgs.findutils pkgs.gnug
|
|||||||
grep -q ignore-widgets $p/prefs.js || fail "prefs.js changed with an own user.js"
|
grep -q ignore-widgets $p/prefs.js || fail "prefs.js changed with an own user.js"
|
||||||
rm $p/user.js
|
rm $p/user.js
|
||||||
|
|
||||||
|
# prefs.js can't be rewritten: it and the link stay; the next launch retries
|
||||||
|
echo 'user_pref("other", 1);' > $p/prefs.js
|
||||||
|
mkdir $p/prefs.js.sfn
|
||||||
|
${launcher} || true
|
||||||
|
grep -q other $p/prefs.js && grep -q ignore-widgets $p/prefs.js || fail "prefs.js lost on a write error"
|
||||||
|
[ -L $p/user.js ] || fail "link removed on a write error"
|
||||||
|
rmdir $p/prefs.js.sfn
|
||||||
|
${launcher} || true
|
||||||
|
[ "$(cat $p/prefs.js)" = 'user_pref("other", 1);' ] || fail "retry: $(cat $p/prefs.js)"
|
||||||
|
[ ! -L $p/user.js ] || fail "retry left the link"
|
||||||
|
|
||||||
# profile manager action: no --profile, no link
|
# profile manager action: no --profile, no link
|
||||||
: > $FAKE/log
|
: > $FAKE/log
|
||||||
${launcher} --ProfileManager || true
|
${launcher} --ProfileManager || true
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
# no longer in use (a second launch that only hands its URL to the running
|
# no longer in use (a second launch that only hands its URL to the running
|
||||||
# Firefox returns at once) removes the link and the value Firefox stored from
|
# Firefox returns at once) removes the link and the value Firefox stored from
|
||||||
# it in prefs.js. A user.js of the user's own is never touched. After a crash
|
# it in prefs.js. A user.js of the user's own is never touched. After a crash
|
||||||
# the next launch or steam-frame-nix-cleanup finishes the removal.
|
# (or a failed rewrite of prefs.js) the next launch or steam-frame-nix-cleanup
|
||||||
|
# finishes the removal.
|
||||||
{ lib, writeShellScript, coreutils, findutils, gnugrep
|
{ lib, writeShellScript, coreutils, findutils, gnugrep
|
||||||
, profileDir # shell word, e.g. "$HOME/.var/app/…/desktop"
|
, profileDir # shell word, e.g. "$HOME/.var/app/…/desktop"
|
||||||
, desktopFix ? false
|
, desktopFix ? false
|
||||||
@@ -33,9 +34,13 @@ writeShellScript "firefox-wrapper" (''
|
|||||||
sfn_unlink() {
|
sfn_unlink() {
|
||||||
ours && ! inUse || return 0
|
ours && ! inUse || return 0
|
||||||
if [ -f "$prof/prefs.js" ] && grep -qF "$pats" "$prof/prefs.js"; then
|
if [ -f "$prof/prefs.js" ] && grep -qF "$pats" "$prof/prefs.js"; then
|
||||||
grep -vF "$pats" "$prof/prefs.js" > "$prof/prefs.js.sfn" || true
|
# If that fails (grep status 2, a failed write, e.g. a full disk),
|
||||||
|
# prefs.js and the link stay for the next try.
|
||||||
|
{ grep -vF "$pats" "$prof/prefs.js"; [ $? -le 1 ]; } > "$prof/prefs.js.sfn" &&
|
||||||
cat "$prof/prefs.js.sfn" > "$prof/prefs.js"
|
cat "$prof/prefs.js.sfn" > "$prof/prefs.js"
|
||||||
|
ok=$?
|
||||||
rm -f "$prof/prefs.js.sfn"
|
rm -f "$prof/prefs.js.sfn"
|
||||||
|
[ $ok = 0 ] || return 0
|
||||||
fi
|
fi
|
||||||
rm -f "$u"
|
rm -f "$u"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user