From ceafc334ccf18a0d90bef35c293cc10c3b891f02 Mon Sep 17 00:00:00 2001 From: Nicolas Benes Date: Tue, 28 Dec 2021 17:01:11 +0100 Subject: [PATCH] tor-browser-bundle-bin: Keep files when store path has not changed Originally, some TBB files in the user's $HOME are always deleted on startup, and as a result, addons are not loaded automatically at startup. For example, NoScript is disabled by default and needs a manual reload cycle (dis-/enable by hand). This change preserves the files with the addon information as long as the contained store path is the same, i.e. TBB was not modified. When TBB is updated, the files are removed as before, so that they don't contain paths to the store location of the (now outdated) previous TBB. A manual reload addon cycle is necessary once. (cherry picked from commit 8985aca004193bd179ab49e49d2eff37d77a44a5) --- .../browsers/tor-browser-bundle-bin/default.nix | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/networking/browsers/tor-browser-bundle-bin/default.nix b/pkgs/applications/networking/browsers/tor-browser-bundle-bin/default.nix index 3f5044a05532..f35ae98f71c4 100644 --- a/pkgs/applications/networking/browsers/tor-browser-bundle-bin/default.nix +++ b/pkgs/applications/networking/browsers/tor-browser-bundle-bin/default.nix @@ -297,10 +297,17 @@ stdenv.mkDerivation rec { cp -u --no-preserve=mode,owner "$TBB_IN_STORE/TorBrowser/Data/Browser/profile.default/bookmarks.html" \ "\$HOME/TorBrowser/Data/Browser/profile.default/bookmarks.html" - # Clear out some files that tend to capture store references but are - # easily generated by firefox at startup. - rm -f "\$HOME/TorBrowser/Data/Browser/profile.default"/{addonStartup.json.lz4,compatibility.ini,extensions.ini,extensions.json} - rm -f "\$HOME/TorBrowser/Data/Browser/profile.default"/startupCache/* + # Clear some files if the last known store path is different from the new one + : "\''${KNOWN_STORE_PATH:=\$HOME/known-store-path}" + if ! [ "\$KNOWN_STORE_PATH" -ef $out ]; then + echo "Cleanup files with outdated store references" + ln -Tsf $out "\$KNOWN_STORE_PATH" + + # Clear out some files that tend to capture store references but are + # easily generated by firefox at startup. + rm -f "\$HOME/TorBrowser/Data/Browser/profile.default"/{addonStartup.json.lz4,compatibility.ini,extensions.ini,extensions.json} + rm -f "\$HOME/TorBrowser/Data/Browser/profile.default"/startupCache/* + fi # XDG : "\''${XDG_RUNTIME_DIR:=/run/user/\$(id -u)}"