1
0
Fork 0

firefox-home-profile/fhp: Added cache-directory support

pull/890/head
tokiclover 10 years ago
parent f3081c8a40
commit f0cfb685ff

@ -2,10 +2,10 @@
# firefox home profile (fhp) module to maintain the profile # firefox home profile (fhp) module to maintain the profile
# in a tmpfs or zram backed filesystem # in a tmpfs or zram backed filesystem
# #
# $Header: firefox-profile/functions/fhp Exp $ # $Header: firefox-home-profile/functions/fhp Exp $
# $Aythor: (c) 2011-2014 -tclover <tokiclover@gmail.com> Exp $ # $Aythor: (c) 2012-2015 -tclover <tokiclover@gmail.com> Exp $
# $License: MIT (or 2-clause/new/simplified BSD) 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 { function die {
@ -15,46 +15,37 @@ function die {
return $ret return $ret
} }
local compressor profile local dir compressor profile tarball
zstyle -s ':prezto:module:FHP' profile 'profile'
zstyle -s ':prezto:module:firefox-profile' profile 'profile' zstyle -s ':prezto:module:FHP' compressor 'compressor'
zstyle -s ':prezto:module:firefox-profile' compressor 'compressor'
local ext=.tar.$compressor[(w)1] local ext=.tar.$compressor[(w)1]
pushd -q "$HOME"/.mozilla/firefox || return for dir ("$HOME"/.{,cache/}mozilla/firefox) {
pushd -q "$dir" || continue
if [[ -f $profile/.unpacked ]] { if [[ -f $profile/.unpacked ]] {
if [[ -f $profile$ext ]] { if [[ -f $profile$ext ]] {
mv -f $profile{,.old}$ext mv -f $profile{,.old}$ext ||
if (( $? )) { { die "Failed to override the old tarball"; continue; }
die "failed to override the old tarball"
return
} }
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 ||
tar -X $profile/.unpacked -Ocp $profile | $=compressor $profile$ext die "Failed to unpack profile tarball"
(( $? )) && die "failed to repack a new tarball"
popd -q 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: # vim:fenc=utf-8:ft=zsh:ci:pi:sts=2:sw=2:ts=2:
# #

Loading…
Cancel
Save