Permalink
Browse files

fixed long standing bug in chrome based profiles and removed the all …

…option
  • Loading branch information...
1 parent 4b97790 commit 5158f590063b6798538caba4385cf6b3d788d1d0 @graysky2 committed Dec 8, 2012
Showing with 13 additions and 99 deletions.
  1. +4 −0 CHANGELOG
  2. +0 −2 README-for_other_distros
  3. +8 −92 profile-cleaner
  4. +1 −5 profile-cleaner.manpage
View
@@ -1,3 +1,7 @@
+v1.91
+08-Dec-2012
+Fixed long standing bug in chrome based profiles and removed the all option.
+
v1.90
06-Dec-2012
Repositioned the 2>/dev/null to be more meaningful.
@@ -8,8 +8,6 @@ DESCRIPTION
Profile-cleaner is a very simple shell script that will invoke sqlite3 to vacuum and reindex databases belonging to supported browsers and email clients. It is compatible with profile-sync-daemon so users need not stop psd before calling profile-cleaner. In fact, profiles will clean much faster when they are synced to tmpfs via psd.
OPTIONS
- a Clean ALL supported profiles (auto-detected).
-
c Clean chromium's profile.
ck Clean conkeror's profile(s)*.
View
@@ -1,6 +1,6 @@
#!/bin/bash
export BLD="\e[01m" RED="\e[01;31m" GRN="\e[01;32m" YLW="\e[01;33m" NRM="\e[00m"
-VERS="1.90"
+VERS="1.91"
if [[ -z $(which parallel) ]]; then
echo -e ${RED}"Error: GNU Parallel is now a requirement of this script. Please install it and try again."${NRM}
@@ -27,99 +27,20 @@ do_clean() {
echo "$name,$dsize" >> /tmp/accounting.$name
}
-do_all() {
-
- ### chrome based ###
-
- for name in chromium google-chrome; do
- export name
- prepath="$XDG_CONFIG_HOME"
- [[ -h "$prepath" ]] && profilepath=$(readlink $prepath) || profilepath="$prepath"
- if [[ ! -d "$profilepath" ]]; then
- echo -en "${BLD} $name${NRM}"
- echo -e "$(tput cr)$(tput cuf 16) ${BLD}[ ]${NRM}"
- else
- echo -en "${BLD} $name${NRM}"
- echo -e "$(tput cr)$(tput cuf 16) ${BLD}[${GRN}X${NRM}${BLD}]${NRM}"
- find "$profilepath" -maxdepth 2 -type f -name 'Histor*' -o -name 'Archiv*' -o -name 'Safe*' >> /tmp/work2do.$name
- fi
- done
-
- ### db based ###
-
- for name in midori qupzilla; do
- export name
- [[ "$name" = "midori" ]] && prepath="$XDG_CONFIG_HOME"/$name
- [[ "$name" = "qupzilla" ]] && prepath=$HOME/.$name/profiles
- [[ -h "$prepath" ]] && profilepath=$(readlink $prepath) || profilepath="$prepath"
-
- if [[ ! -d "$profilepath" ]]; then
- echo -en "${BLD} $name${NRM}"
- echo -e "$(tput cr)$(tput cuf 16) ${BLD}[ ]${NRM}"
- else
- echo -en "${BLD} $name${NRM}"
- echo -e "$(tput cr)$(tput cuf 16) ${BLD}[${GRN}X${NRM}${BLD}]${NRM}"
- find "$profilepath" -maxdepth 2 -type f -name '*.db' >> /tmp/work2do.$name
- fi
- done
-
- ### xul based ###
-
- for name in firefox conkeror aurora thunderbird; do
- [[ "$name" = "firefox" ]] && prepath=$HOME/.mozilla/$name
- [[ "$name" = "conkeror" ]] && prepath=$HOME/.conkeror.mozdev.org/$name
- [[ "$name" = "aurora" ]] && prepath=$HOME/.mozilla/aurora
- [[ "$name" = "thunderbird" ]] && prepath=$HOME/.$name
- export name
-
- [[ -h "$prepath" ]] && profilepath=$(readlink $prepath) || profilepath="$prepath"
-
- if [[ ! -f "$profilepath"/profiles.ini ]]; then
- echo -en "${BLD} $name${NRM}"
- echo -e "$(tput cr)$(tput cuf 16) ${BLD}[ ]${NRM}"
- else
- echo -en "${BLD} $name${NRM}"
- echo -e "$(tput cr)$(tput cuf 16) ${BLD}[${GRN}X${NRM}${BLD}]${NRM}"
- workArr=( $(grep '[P,p]'ath $profilepath/profiles.ini | sed -e 's/[P,p]ath=//' -e 's/\r//') )
- for i in "${workArr[@]}"; do
- if [ ! -d "$profilepath/$i" ]; then
- find "$i" -maxdepth 4 -type f -name '*.db' >> /tmp/work2do.$name
- find "$profilepath" -maxdepth 2 -type f -name '*.db' >> /tmp/work2do.$name
- fi
- done
- fi
- done
-
- ### run cleaner ###
-
- echo
-
- for i in /tmp/work2do.*; do
- name=${i##*.}
- export name
- cat $i | SHELL=/bin/bash parallel do_clean 2>/dev/null
- done
-
- ### report savings and remove temp files ###
-
- echo
-
- for i in /tmp/accounting.*; do
- name=${i##*.}
- echo -e " ${BLD}Profile(s) for ${i##*.} reduced by ${YLW}$(grep $name $i | gawk -F, '{ print $2 }' | paste -sd+ - | bc)${NRM} ${BLD}Mbytes.${NRM}"
- done
-
- find /tmp -name 'work2do.*' -o -name 'accounting.*' -o -name "totalwork2do" | SHELL=/bin/bash parallel rm -f
+find_dbs() {
+ find "$profilepath" -maxdepth 2 -type f| while read i; do
+ [[ -n $(file "$i" | grep SQLite) ]] && echo "${i}" >> /tmp/work2do.$name
+done
}
do_chromebased() {
[[ -h "$prepath" ]] && profilepath=$(readlink $prepath) || profilepath="$prepath"
[[ ! -d "$profilepath" ]] && echo -e ${RED}"Error: no profile directory for $name found."${NRM} && exit 1
echo -e " ${YLW}Cleaning profile for $name${NRM}"
- find "$profilepath" -maxdepth 2 -type f -name 'Histor*' -o -name 'Archiv*' -o -name 'Safe*' | SHELL=/bin/bash parallel -k do_clean 2>/dev/null
- echo
+ find_dbs && cat /tmp/work2do.$name | SHELL=/bin/bash parallel -k do_clean 2>/dev/null
echo -e " ${BLD}Profile for $name reduced by ${YLW}$(grep $name /tmp/accounting.$name | gawk -F, '{ print $2 }' | paste -sd+ - | bc)${NRM} ${BLD}Mbytes.${NRM}"
[[ -f /tmp/accounting.$name ]] && rm -f /tmp/accounting.$name
+ [[ -f /tmp/work2do.$name ]] && rm -f /tmp/work2do.$name
}
do_xulbased() {
@@ -175,10 +96,6 @@ do_dbbased() {
export -f do_clean
case "$1" in
- A|a)
- do_all
- exit 0
- ;;
C|c)
name="chromium" ; export name
prepath="$XDG_CONFIG_HOME"/$name
@@ -228,9 +145,8 @@ case "$1" in
exit 0
;;
*)
- echo -e " ${BLD}$0 ${NRM}${GRN}{a|c|ck|f|gc|h|m|t|q}${NRM}"
+ echo -e " ${BLD}$0 ${NRM}${GRN}{c|ck|f|gc|h|m|t|q}${NRM}"
echo
- echo -e " ${BLD}a) ${GRN}A${NRM}${BLD}ll supported profiles (auto-detected)"${NRM}
echo -e " ${BLD}c) ${GRN}C${NRM}${BLD}hromium"${NRM}
echo -e " ${BLD}ck) ${GRN}C${NRM}${BLD}on${GRN}k${NRM}${BLD}eror"${NRM}
echo -e " ${BLD}f) ${GRN}F${NRM}${BLD}irefox"${NRM}
@@ -1,5 +1,5 @@
.\" Text automatically generated by txt2man
-.TH profile-cleaner 1 "30 November 2012" "" ""
+.TH profile-cleaner 1 "08 December 2012" "" ""
.SH NAME
\fBprofile-cleaner \fP- Reduce the size of browser and some email program's profiles by organizing their sqlite databases using sqlite3's vacuum and reindex functions.
\fB
@@ -17,10 +17,6 @@ Profile-cleaner is a very simple shell script that will invoke sqlite3 to vacuum
.SH OPTIONS
.TP
.B
-a
-Clean ALL supported profiles (auto-detected).
-.TP
-.B
c
Clean chromium's profile.
.TP

0 comments on commit 5158f59

Please sign in to comment.