Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

reports the total amount of space recovered after the clean operation

  • Loading branch information...
commit a939f3395e716c1691b9cf88ea7023a893071e5d 1 parent 448280f
@graysky2 authored
View
4 CHANGELOG
@@ -1,3 +1,7 @@
+v1.83
+30-Nov-2012
+Now reports a total amount of space recovered.
+
v1.82
29-Nov-2012
Streamlined code and added support for midori.
View
6 README-for_other_distros
@@ -39,8 +39,6 @@ Size before: 154.17 Mbytes
Size after: 99.11 Mbytes
-Recovered: 55.06 Mbytes
-
$ profile-cleaner f
/home/facade/.mozilla/firefox/zee52krz.default/cookies.sqlite reduced by .87 Mbytes
@@ -58,6 +56,8 @@ Recovered: 55.06 Mbytes
/home/facade/.mozilla/firefox/zee52krz.default/search.sqlite reduced by 0 Mbytes
/home/facade/.mozilla/firefox/zee52krz.default/places.sqlite reduced by 9.98 Mbytes
+ firefox profile reduced by 55.06 Mbytes
+
CONTRIBUTE
Should you wish to contribute to this code, please fork and send a pull request. Source is freely available on github: https://github.com/graysky2/profile-cleaner
@@ -68,4 +68,4 @@ AUTHOR
graysky (graysky AT archlinux DOT us)
SEE ALSO
-profile-sync-deamon (8)
+profile-sync-deamon (1)
View
3  README.md
@@ -14,7 +14,6 @@ AUR Link: https://aur.archlinux.org/packages/profile-cleaner
Size before: 154.17 Mbytes
Size after: 99.11 Mbytes
- Recovered: 55.06 Mbytes
$ profile-cleaner f
@@ -33,6 +32,8 @@ AUR Link: https://aur.archlinux.org/packages/profile-cleaner
/home/facade/.mozilla/firefox/zee52krz.default/search.sqlite reduced by 0 Mbytes
/home/facade/.mozilla/firefox/zee52krz.default/places.sqlite reduced by 9.98 Mbytes
+ firefox profile reduced by 55.06 Mbytes
+
## Speed Comparison
28-Nov-2012 Profile-cleaner has been rewritten to use GNU Parallel for processing.
View
78 profile-cleaner
@@ -1,6 +1,6 @@
#!/bin/bash
-VERS="1.82"
+VERS="1.83"
if [[ -z $(which parallel) ]]; then
echo "GNU Parallel is now a requirement of this script."
@@ -8,6 +8,8 @@ if [[ -z $(which parallel) ]]; then
exit 1
fi
+[[ -f /tmp/accounting.db ]] && rm -f /tmp/accounting.db
+
echo -en "\E[31mprofile-cleaner v$VERS"
tput sgr0
echo
@@ -20,12 +22,16 @@ do_clean() {
asize=$(ls -l "$1" | awk {'print $5'})
dsize=$(echo "scale=2; ($bsize-$asize)/1048576" | bc)
echo "$1" reduced by $dsize Mbytes
+ echo "$name,$dsize" >> /tmp/accounting.db
}
do_chromebased() {
[[ -h "$prepath" ]] && profilepath=$(readlink $prepath) || profilepath="$prepath"
- [[ ! -d "$profilepath" ]] && echo "Error: no profile directory found." && exit 1
- find ${profilepath} -maxdepth 2 -type f -name 'Histor*' -o -name 'Archiv*' -o -name 'Safe*' | SHELL=/bin/bash parallel do_clean 2>/dev/null
+ [[ ! -d "$profilepath" ]] && echo "Error: no profile directory for $name found." && exit 1
+ find "$profilepath" -maxdepth 2 -type f -name 'Histor*' -o -name 'Archiv*' -o -name 'Safe*' | SHELL=/bin/bash parallel do_clean 2>/dev/null
+ echo
+ echo "$name profile reduced by $(grep $name /tmp/accounting.db | gawk -F, '{ print $2 }' | paste -sd+ - | bc) Mbytes"
+ [[ -f /tmp/accounting.db ]] && rm -f /tmp/accounting.db
}
do_xulbased() {
@@ -35,12 +41,15 @@ do_xulbased() {
profilepath="$prepath"
fi
+ [[ "$name" = "aurora" ]] && name="heftig aurora"
+
if [[ ! -d "$profilepath" ]]; then
echo "Error: cannot locate $profilepath"
+ echo "This is the default path for $name and where $0 expects to find it."
exit 1
fi
- [[ ! -f $profilepath/profiles.ini ]] && echo "Error: cannot locate $profilepath/profiles.ini to determine names of profiles." && exit 1
+ [[ ! -f $profilepath/profiles.ini ]] && echo "Error: cannot locate $profilepath/profiles.ini to determine names of profiles for $name." && exit 1
# workArr is a raw list of profiles
workArr=( $(grep '[P,p]'ath $profilepath/profiles.ini | sed -e 's/[P,p]ath=//' -e 's/\r//') ) # read each profile into the work array
@@ -59,61 +68,80 @@ do_xulbased() {
# here is the actual worker
find -L ${FinalArr[@]} -maxdepth 2 -name '*.sqlite' | SHELL=/bin/bash parallel do_clean 2>/dev/null
+ echo
+ echo "$name profile(s) reduced by $(grep $name /tmp/accounting.db | gawk -F, '{ print $2 }' | paste -sd+ - | bc) Mbytes"
+ [[ -f /tmp/accounting.db ]] && rm -f /tmp/accounting.db
}
do_dbbased() {
[[ -h "$prepath" ]] && profilepath=$(readlink $prepath) || profilepath="$prepath"
- [[ ! -d "$profilepath" ]] && echo "Error: no profile directory for midori found." && exit 1
+ [[ ! -d "$profilepath" ]] && echo "Error: no profile directory for $name found." && exit 1
find ${profilepath} -maxdepth 2 -type f -name '*.db' | SHELL=/bin/bash parallel do_clean 2>/dev/null
+ echo
+ echo "$name profile reduced by $(grep $name /tmp/accounting.db | gawk -F, '{ print $2 }' | paste -sd+ - | bc) Mbytes"
}
export -f do_clean
case "$1" in
- c)
- prepath=$XDG_CONFIG_HOME/chromium
+ C|c)
+ name="chromium" ; export name
+ prepath=$XDG_CONFIG_HOME/$name
do_chromebased
exit 0
;;
- gc)
- prepath=$XDG_CONFIG_HOME/google-chrome
+ Gc|gC|GC|gc)
+ name="google-chrome" ; export name
+ prepath=$XDG_CONFIG_HOME/$name
do_chromebased
exit 0
;;
- f)
- prepath=$HOME/.mozilla/firefox
+ F|f)
+ name="firefox"; export name
+ prepath=$HOME/.mozilla/$name
do_xulbased
exit 0
;;
- ck)
- prepath=$HOME/.conkeror.mozdev.org/conkeror
+ CK|cK|Ck|ck)
+ name="conkeror"; export name
+ prepath=$HOME/.conkeror.mozdev.org/$name
do_xulbased
exit 0
;;
- h)
+ H|h)
+ name="heftig aurora"; export name
prepath=$HOME/.mozilla/aurora
do_xulbased
exit 0
;;
- t)
- prepath=$HOME/.thunderbird
+ T|t)
+ name="thunderbird"; export name
+ prepath=$HOME/.$name
do_xulbased
exit 0
;;
- m)
- prepath=$XDG_CONFIG_HOME/midori
+ M|m)
+ name="midori"; export name
+ prepath=$XDG_CONFIG_HOME/$name
+ do_dbbased
+ exit 0
+ ;;
+ Q|q)
+ name="qupzilla"; export name
+ prepath=$HOME/.$name/profiles
do_dbbased
exit 0
;;
*)
echo "$0 {a|c|ck|f|gc|t}"
- echo " c) chromium"
- echo "ck) conkeror"
- echo " f) firefox"
- echo "gc) google chrome"
- echo " h) heftig's aurora"
- echo " m) midori"
- echo " t) thunderbird"
+ echo " c) Chromium"
+ echo "ck) Conkeror"
+ echo " f) Firefox"
+ echo "gc) Google Chrome"
+ echo " h) Heftig's Aurora"
+ echo " m) Midori"
+ echo " t) Thunderbird"
+ echo " q) QupZilla"
exit 0
;;
esac
View
8 profile-cleaner.manpage
@@ -1,5 +1,5 @@
.\" Text automatically generated by txt2man
-.TH profile-cleaner 1 "29 November 2012" "" ""
+.TH profile-cleaner 1 "30 November 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
@@ -66,8 +66,6 @@ Midori
Size before: 154.17 Mbytes
.PP
Size after: 99.11 Mbytes
-.PP
-Recovered: 55.06 Mbytes
.RE
.PP
@@ -89,6 +87,8 @@ Recovered: 55.06 Mbytes
/home/facade/.mozilla/firefox/zee52krz.default/search.sqlite reduced by 0 Mbytes
/home/facade/.mozilla/firefox/zee52krz.default/places.sqlite reduced by 9.98 Mbytes
+ firefox profile reduced by 55.06 Mbytes
+
.fam T
.fi
.SH CONTRIBUTE
@@ -98,4 +98,4 @@ None known.
.SH AUTHOR
graysky (graysky AT archlinux DOT us)
.SH SEE ALSO
-profile-sync-deamon (8)
+profile-sync-deamon (1)
Please sign in to comment.
Something went wrong with that request. Please try again.