firefox-home-profile/fhp: Added cache-directory support
This commit is contained in:
parent
f3081c8a40
commit
f0cfb685ff
1 changed files with 28 additions and 37 deletions
|
@ -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 <tokiclover@gmail.com> Exp $
|
||||
# $Header: firefox-home-profile/functions/fhp Exp $
|
||||
# $Aythor: (c) 2012-2015 -tclover <tokiclover@gmail.com> 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:
|
||||
#
|
||||
|
|
Loading…
Add table
Reference in a new issue