From f0cfb685ff7e8d108930967ebc538d85d6dba49c Mon Sep 17 00:00:00 2001 From: tokiclover Date: Sun, 10 May 2015 16:23:21 +0200 Subject: [PATCH] firefox-home-profile/fhp: Added cache-directory support --- modules/firefox-home-profile/functions/fhp | 65 ++++++++++------------ 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/modules/firefox-home-profile/functions/fhp b/modules/firefox-home-profile/functions/fhp index 779e5a1e..91ce5d95 100644 --- a/modules/firefox-home-profile/functions/fhp +++ b/modules/firefox-home-profile/functions/fhp @@ -2,10 +2,10 @@ # firefox home profile (fhp) module to maintain the profile # in a tmpfs or zram backed filesystem # -# $Header: firefox-profile/functions/fhp Exp $ -# $Aythor: (c) 2011-2014 -tclover Exp $ +# $Header: firefox-home-profile/functions/fhp Exp $ +# $Aythor: (c) 2012-2015 -tclover Exp $ # $License: MIT (or 2-clause/new/simplified BSD) Exp $ -# $Version: 3.0 2014/09/30 Exp $ +# $Version: 4.0 2015/05/05 Exp $ # function die { @@ -15,46 +15,37 @@ function die { return $ret } -local compressor profile - -zstyle -s ':prezto:module:firefox-profile' profile 'profile' -zstyle -s ':prezto:module:firefox-profile' compressor 'compressor' - +local dir compressor profile tarball +zstyle -s ':prezto:module:FHP' profile 'profile' +zstyle -s ':prezto:module:FHP' compressor 'compressor' local ext=.tar.$compressor[(w)1] -pushd -q "$HOME"/.mozilla/firefox || return - -if [[ -f $profile/.unpacked ]] { - if [[ -f $profile$ext ]] { - mv -f $profile{,.old}$ext - if (( $? )) { - die "failed to override the old tarball" - return +for dir ("$HOME"/.{,cache/}mozilla/firefox) { + pushd -q "$dir" || continue + if [[ -f $profile/.unpacked ]] { + if [[ -f $profile$ext ]] { + mv -f $profile{,.old}$ext || + { die "Failed to override the old tarball"; continue; } } + tar -X $profile/.unpacked -Ocp $profile | $=compressor $profile$ext || + die "Failed to repack a new tarball" + popd -q + } else { + compressor=$compressor[(w)1] + if [[ -f $profile$ext ]] { + tarball=$profile$ext + } elif [[ -f $profile.old$ext ]] { + tarball=$profile.old$ext + } else { + die "No tarball found" + continue + } + $compressor -cd $tarball | tar -xp && touch $profile/.unpacked || + die "Failed to unpack profile tarball" + popd -q } - - tar -X $profile/.unpacked -Ocp $profile | $=compressor $profile$ext - (( $? )) && die "failed to repack a new tarball" - - popd -q - return -} - -compressor=$compressor[(w)1] -if [[ -f $profile$ext ]] { - local tarball=$profile$ext -} elif [[ -f $profile.old$ext ]] { - local tarball=$profile.old$ext -} else { - die "no tarball found" - return } -$compressor -cd $tarball | tar -xp && touch $profile/.unpacked -(( $? )) && die "failed to unpack the profile" - -popd -q - # # vim:fenc=utf-8:ft=zsh:ci:pi:sts=2:sw=2:ts=2: #