[Slim-Checkins] r33823 - in /7.7/trunk/server: cleanup.pl strings.txt

[email protected] Mon, 13 Feb 2012 10:21:22 -0000
Newsgroups gmane.music.equipment.slimdevices.cvs
Message-ID <[email protected]>
Author: mherger
Date: Mon Feb 13 02:21:21 2012
New Revision: 33823

URL: http://svn.slimdevices.com/slim?rev=33823&view=rev
Log:
Bug: n/a
Description: improve cleanup script to include more of the new db files. Add option to test-run the cleanup (--dryrun)

Modified:
    7.7/trunk/server/cleanup.pl
    7.7/trunk/server/strings.txt

Modified: 7.7/trunk/server/cleanup.pl
URL: http://svn.slimdevices.com/slim/7.7/trunk/server/cleanup.pl?rev=33823&r1=33822&r2=33823&view=diff
==============================================================================
--- 7.7/trunk/server/cleanup.pl (original)
+++ 7.7/trunk/server/cleanup.pl Mon Feb 13 02:21:21 2012
@@ -14,10 +14,12 @@
 require 5.008_001;
 
 use constant SPLASH_LOGO => 'lms_splash.png';
+use constant ISWINDOWS    => ( $^O =~ /^m?s?win/i ) ? 1 : 0;
+use constant ISMAC        => ( $^O =~ /darwin/i ) ? 1 : 0;
 
 # don't use Wx, if script is run using perl on OSX, it needs to be run using wxperl
 my $splash;
-my $useWx = ($^O !~ /darwin/ || $^X =~ /wxPerl/i) && eval {
+my $useWx = (!ISMAC || $^X =~ /wxPerl/i) && eval {
 	require Wx;
 	
 	showSplashScreen();
@@ -28,7 +30,7 @@
 	return 1;
 };
 
-print "$@\n" if $@;
+print "$@\n" if $@ && ISWINDOWS;
 
 use strict;
 use Socket;
@@ -38,8 +40,6 @@
 use constant SCANNER      => 0;
 use constant RESIZER      => 0;
 use constant DEBUG        => 1;
-use constant ISWINDOWS    => ( $^O =~ /^m?s?win/i ) ? 1 : 0;
-use constant ISMAC        => ( $^O =~ /darwin/i ) ? 1 : 0;
 use constant TRANSCODING  => 0;
 use constant PERFMON      => 0;
 use constant DEBUGLOG     => 0;
@@ -80,7 +80,7 @@
 		exit;
 	}
 
-	my ($all, $cache, $filecache, $database, $prefs, $logs);
+	my ($all, $cache, $filecache, $database, $prefs, $logs, $dryrun);
 	
 	Getopt::Long::GetOptions(
 		'all'       => \$all,
@@ -89,6 +89,7 @@
 		'prefs'     => \$prefs,
 		'logs'      => \$logs,
 		'database'  => \$database,
+		'dryrun'    => \$dryrun,
 	);
 	
 	my $folders = getFolderList({
@@ -123,7 +124,7 @@
 		}
 	}
 
-	cleanup($folders);
+	cleanup($folders, $dryrun);
 	
 	print sprintf("\n%s\n\n", Slim::Utils::Light::string('CLEANUP_PLEASE_RESTART_SC'));
 }
@@ -142,6 +143,8 @@
 	--cache   (!)  %s
 
 	--all     (!!) %s
+	
+	--dryrun       %s
 	
 EOF
 	print sprintf($usage, 
@@ -153,6 +156,7 @@
 		Slim::Utils::Light::string('CLEANUP_LOGS'),
 		Slim::Utils::Light::string('CLEANUP_CACHE'),
 		Slim::Utils::Light::string('CLEANUP_ALL'),
+		Slim::Utils::Light::string('CLEANUP_DRYRUN'),
 	);
 }
 
@@ -163,6 +167,26 @@
 	my $cacheFolder = Slim::Utils::Light::getPref('cachedir') || $os->dirsFor('cache');
 
 	push @folders, _target('cache', 'cache') if ($args->{all} || $args->{cache});
+	
+	push @folders, {
+		label   => 'some legacy files',
+		folders => [
+			File::Spec::Functions::catdir($cacheFolder, 'MySQL'),
+			File::Spec::Functions::catdir($cacheFolder, 'my.cnf'),
+			File::Spec::Functions::catdir($cacheFolder, 'squeezecenter-mysql.pid'),
+			File::Spec::Functions::catdir($cacheFolder, 'squeezecenter-mysql.sock'),
+			File::Spec::Functions::catdir($cacheFolder, 'mysql-error-log.txt'),
+			File::Spec::Functions::catdir($cacheFolder, 'squeezebox.db'),
+			File::Spec::Functions::catdir($cacheFolder, 'squeezebox.db-shm'),
+			File::Spec::Functions::catdir($cacheFolder, 'squeezebox.db-wal'),
+			File::Spec::Functions::catdir($cacheFolder, 'squeezebox-persistent.db'),
+			File::Spec::Functions::catdir($cacheFolder, 'squeezebox-persistent.db-shm'),
+			File::Spec::Functions::catdir($cacheFolder, 'squeezebox-persistent.db-wal'),
+			File::Spec::Functions::catdir($cacheFolder, 'ArtworkCache.db'),
+			File::Spec::Functions::catdir($cacheFolder, 'ArtworkCache.db-shm'),
+			File::Spec::Functions::catdir($cacheFolder, 'ArtworkCache.db-wal'),
+		],
+	};
 	
 	if ($args->{filecache}) {
 		push @folders, {
@@ -175,8 +199,17 @@
 				File::Spec::Functions::catdir($cacheFolder, 'fonts.bin'),
 				File::Spec::Functions::catdir($cacheFolder, 'strings.bin'),
 				File::Spec::Functions::catdir($cacheFolder, 'templates'),
+				File::Spec::Functions::catdir($cacheFolder, 'updates'),
 				File::Spec::Functions::catdir($cacheFolder, 'cookies.dat'),
 				File::Spec::Functions::catdir($cacheFolder, 'plugin-data.yaml'),
+
+				File::Spec::Functions::catdir($cacheFolder, 'cache.db'),
+				File::Spec::Functions::catdir($cacheFolder, 'cache.db-shm'),
+				File::Spec::Functions::catdir($cacheFolder, 'cache.db-wal'),
+
+				File::Spec::Functions::catdir($cacheFolder, 'artwork.db'),
+				File::Spec::Functions::catdir($cacheFolder, 'artwork.db-shm'),
+				File::Spec::Functions::catdir($cacheFolder, 'artwork.db-wal'),
 			],
 		};
 	}
@@ -195,25 +228,6 @@
 				File::Spec::Functions::catdir($cacheFolder, 'persist.db'),
 				File::Spec::Functions::catdir($cacheFolder, 'persist.db-shm'),
 				File::Spec::Functions::catdir($cacheFolder, 'persist.db-wal'),
-				File::Spec::Functions::catdir($cacheFolder, 'artwork.db'),
-				File::Spec::Functions::catdir($cacheFolder, 'artwork.db-shm'),
-				File::Spec::Functions::catdir($cacheFolder, 'artwork.db-wal'),
-
-				# some legacy files...
-				File::Spec::Functions::catdir($cacheFolder, 'MySQL'),
-				File::Spec::Functions::catdir($cacheFolder, 'my.cnf'),
-				File::Spec::Functions::catdir($cacheFolder, 'squeezecenter-mysql.pid'),
-				File::Spec::Functions::catdir($cacheFolder, 'squeezecenter-mysql.sock'),
-				File::Spec::Functions::catdir($cacheFolder, 'mysql-error-log.txt'),
-				File::Spec::Functions::catdir($cacheFolder, 'squeezebox.db'),
-				File::Spec::Functions::catdir($cacheFolder, 'squeezebox.db-shm'),
-				File::Spec::Functions::catdir($cacheFolder, 'squeezebox.db-wal'),
-				File::Spec::Functions::catdir($cacheFolder, 'squeezebox-persistent.db'),
-				File::Spec::Functions::catdir($cacheFolder, 'squeezebox-persistent.db-shm'),
-				File::Spec::Functions::catdir($cacheFolder, 'squeezebox-persistent.db-wal'),
-				File::Spec::Functions::catdir($cacheFolder, 'ArtworkCache.db'),
-				File::Spec::Functions::catdir($cacheFolder, 'ArtworkCache.db-shm'),
-				File::Spec::Functions::catdir($cacheFolder, 'ArtworkCache.db-wal'),
 			],
 		};
 	}
@@ -302,10 +316,8 @@
 }
 
 sub cleanup {
-	my $folders = shift;
-
-	my $fallbackFolder = $os->dirsFor('');
-		
+	my ($folders, $dryrun) = @_;
+
 	for my $item (@$folders) {
 		print sprintf("\n%s %s...\n", Slim::Utils::Light::string('CLEANUP_DELETING'), $item->{label}) unless $useWx;
 		
@@ -313,6 +325,8 @@
 			next unless $_;
 			
 			print "-> $_\n" if (-e $_ && !$useWx);
+			
+			next if $dryrun;
 
 			if (-d $_) {
 				File::Path::rmtree($_);

Modified: 7.7/trunk/server/strings.txt
URL: http://svn.slimdevices.com/slim/7.7/trunk/server/strings.txt?rev=33823&r1=33822&r2=33823&view=diff
==============================================================================
--- 7.7/trunk/server/strings.txt (original)
+++ 7.7/trunk/server/strings.txt Mon Feb 13 02:21:21 2012
@@ -23134,6 +23134,10 @@
 	PL	Usuń wszystkie - nie rób tego, jeśli nie masz całkowitej pewności!
 	RU	Очистить все — не выполняйте эту команду, если не уверены!
 	SV	Utplåna allt – Gör inte detta om du inte är helt säker på vad du gör!
+	
+CLEANUP_DRYRUN
+	DE	Bereinigung nicht wirklich durchführen, aber eine Liste der betroffenen Ordner und Dateien anzeigen.
+	EN	Don't actually run the cleanup, but show which files and folders would be removed.
 
 CLEANUP_DELETING
 	CS	Mazání

_______________________________________________
checkins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/checkins