[Slim-Checkins] r11754 - in /trunk/server: Slim/Music/Import.pm Slim/Plugin/Favorites/OpmlFavorites.pm Slim/Plugin/Podcast/Settings.pm Slim/Plugin/RSSNews/Settings.pm Slim/Utils/Prefs.pm Slim/Utils/Prefs/OldPrefs.pm scanner.pl slimserver.pl
adrian at svn.slimdevices.com
adrian at svn.slimdevices.com
Thu Apr 12 10:38:20 PDT 2007
Author: adrian
Date: Thu Apr 12 10:38:19 2007
New Revision: 11754
URL: http://svn.slimdevices.com?rev=11754&view=rev
Log:
Bug: N/A
Description:
- try harder to find the old perferences file
- add new cmdline option --prefdir to allow the new style prefs
directory to be specified
- allow plugins to load if no old prefs file found
Modified:
trunk/server/Slim/Music/Import.pm
trunk/server/Slim/Plugin/Favorites/OpmlFavorites.pm
trunk/server/Slim/Plugin/Podcast/Settings.pm
trunk/server/Slim/Plugin/RSSNews/Settings.pm
trunk/server/Slim/Utils/Prefs.pm
trunk/server/Slim/Utils/Prefs/OldPrefs.pm
trunk/server/scanner.pl
trunk/server/slimserver.pl
Modified: trunk/server/Slim/Music/Import.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Music/Import.pm?rev=11754&r1=11753&r2=11754&view=diff
==============================================================================
--- trunk/server/Slim/Music/Import.pm (original)
+++ trunk/server/Slim/Music/Import.pm Thu Apr 12 10:38:19 2007
@@ -82,6 +82,8 @@
$args->{"prefsfile=$::prefsfile"} = 1;
}
+ $args->{ "prefsdir=" . Slim::Utils::Prefs->dir } = 1;
+
if (Slim::Utils::Log->writeConfig) {
$args->{sprintf("logconfig=%s", Slim::Utils::Log->defaultConfigFile)} = 1;
Modified: trunk/server/Slim/Plugin/Favorites/OpmlFavorites.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/Favorites/OpmlFavorites.pm?rev=11754&r1=11753&r2=11754&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/Favorites/OpmlFavorites.pm (original)
+++ trunk/server/Slim/Plugin/Favorites/OpmlFavorites.pm Thu Apr 12 10:38:19 2007
@@ -93,8 +93,8 @@
$log->info("No opml favorites file found - loading old favorites");
- my @urls = @{Slim::Utils::Prefs::OldPrefs->get('favorite_urls')};
- my @titles = @{Slim::Utils::Prefs::OldPrefs->get('favorite_titles')};
+ my @urls = @{Slim::Utils::Prefs::OldPrefs->get('favorite_urls') || []};
+ my @titles = @{Slim::Utils::Prefs::OldPrefs->get('favorite_titles') || []} ;
while (@urls) {
Modified: trunk/server/Slim/Plugin/Podcast/Settings.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/Podcast/Settings.pm?rev=11754&r1=11753&r2=11754&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/Podcast/Settings.pm (original)
+++ trunk/server/Slim/Plugin/Podcast/Settings.pm Thu Apr 12 10:38:19 2007
@@ -33,8 +33,8 @@
# migrate old prefs across
$prefs->migrate(1, sub {
- my @names = @{Slim::Utils::Prefs::OldPrefs->get('plugin_podcast_names')};
- my @values = @{Slim::Utils::Prefs::OldPrefs->get('plugin_podcast_feeds')};
+ my @names = @{Slim::Utils::Prefs::OldPrefs->get('plugin_podcast_names') || [] };
+ my @values = @{Slim::Utils::Prefs::OldPrefs->get('plugin_podcast_feeds') || [] };
my @feeds;
for my $name (@names) {
@@ -45,6 +45,8 @@
$prefs->set('feeds', \@feeds);
$prefs->set('modified', 1);
}
+
+ 1;
});
# migrate to latest version of default feeds if they have not been modified
Modified: trunk/server/Slim/Plugin/RSSNews/Settings.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/RSSNews/Settings.pm?rev=11754&r1=11753&r2=11754&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/RSSNews/Settings.pm (original)
+++ trunk/server/Slim/Plugin/RSSNews/Settings.pm Thu Apr 12 10:38:19 2007
@@ -46,8 +46,8 @@
# migrate old prefs across
$prefs->migrate(1, sub {
- my @names = @{Slim::Utils::Prefs::OldPrefs->get('plugin_RssNews_names')};
- my @values = @{Slim::Utils::Prefs::OldPrefs->get('plugin_RssNews_feeds')};
+ my @names = @{Slim::Utils::Prefs::OldPrefs->get('plugin_RssNews_names') || [] };
+ my @values = @{Slim::Utils::Prefs::OldPrefs->get('plugin_RssNews_feeds') || [] };
my @feeds;
for my $name (@names) {
@@ -60,6 +60,8 @@
}
$prefs->set('items_per_feed', Slim::Utils::Prefs::OldPrefs->get('plugin_RssNews_items_per_feed') || 3);
+
+ 1;
});
# migrate to latest version of default feeds if they have not been modified
Modified: trunk/server/Slim/Utils/Prefs.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Utils/Prefs.pm?rev=11754&r1=11753&r2=11754&view=diff
==============================================================================
--- trunk/server/Slim/Utils/Prefs.pm (original)
+++ trunk/server/Slim/Utils/Prefs.pm Thu Apr 12 10:38:19 2007
@@ -1297,10 +1297,16 @@
use Slim::Utils::Prefs::OldPrefs;
use Exporter::Lite;
+use Getopt::Long qw(:config pass_through);
our @EXPORT = qw(preferences);
-my $path = Slim::Utils::OSDetect::dirsFor('prefs');
+my $path; # path to directory where preferences are stored
+
+# we need to check for prefsdir being set on cmdline as we are run before the server parses options
+Getopt::Long::GetOptions('prefsdir=s' => \$path);
+
+$path ||= Slim::Utils::OSDetect::dirsFor('prefs');
my $prefs = preferences('server');
@@ -1342,12 +1348,20 @@
0;
});
+
+ unless (-d $path && -w $path) {
+ logError("unable to write to preferences directory $path");
+ }
}
sub writeAll {
for my $n (values %namespaces) {
$n->savenow;
}
+}
+
+sub dir {
+ return $path;
}
=head2 SEE ALSO
Modified: trunk/server/Slim/Utils/Prefs/OldPrefs.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Utils/Prefs/OldPrefs.pm?rev=11754&r1=11753&r2=11754&view=diff
==============================================================================
--- trunk/server/Slim/Utils/Prefs/OldPrefs.pm (original)
+++ trunk/server/Slim/Utils/Prefs/OldPrefs.pm Thu Apr 12 10:38:19 2007
@@ -17,6 +17,9 @@
use YAML::Syck;
use FindBin qw($Bin);
use File::Spec::Functions qw(:ALL);
+use Slim::Utils::Log;
+
+my $log = logger('prefs');
my $oldprefs;
@@ -30,7 +33,7 @@
my $class = shift;
my $pref = shift;
- $oldprefs ||= LoadFile(_oldPath());
+ $oldprefs ||= eval { LoadFile(_oldPath()) } || {};
$oldprefs->{ $pref };
}
@@ -46,33 +49,49 @@
my $client = shift;
my $pref = shift;
- $oldprefs ||= LoadFile(_oldPath());
+ $oldprefs ||= eval { LoadFile(_oldPath()) } || {};
$oldprefs->{'clients'}->{ $client->id }->{ $pref } if $oldprefs->{'clients'}->{ $client->id };
}
sub _oldPath {
+ my $oldPrefs;
+
if (Slim::Utils::OSDetect::OS() eq 'mac') {
- return catdir($ENV{'HOME'}, 'Library', 'SlimDevices', 'slimserver.pref');
+ $oldPrefs = catdir($ENV{'HOME'}, 'Library', 'SlimDevices', 'slimserver.pref');
} elsif (Slim::Utils::OSDetect::OS() eq 'win') {
- return catdir($Bin, 'slimserver.pref');
+ $oldPrefs = catdir($Bin, 'slimserver.pref');
+
+ } elsif (-r $::prefsfile) {
+
+ $oldPrefs = $::prefsfile;
} elsif (-r '/etc/slimserver.conf') {
- return '/etc/slimserver.conf';
+ $oldPrefs = '/etc/slimserver.conf';
} elsif (-r catdir(Slim::Utils::OSDetect::dirsFor('prefs'), 'slimserver.pref')) {
- return catdir(Slim::Utils::OSDetect::dirsFor('prefs'), 'slimserver.pref');
+ $oldPrefs = catdir(Slim::Utils::OSDetect::dirsFor('prefs'), 'slimserver.pref');
+
+ } elsif (-r catdir($ENV{'HOME'}, 'slimserver.pref')) {
+
+ $oldPrefs = catdir($ENV{'HOME'}, 'slimserver.pref');
} else {
- return catdir($ENV{'HOME'}, 'slimserver.pref');
+ $log->warn("no old preference file found - using default preferences");
+
+ return undef;
}
+
+ $log->info("using old preference file $oldPrefs for conversion");
+
+ return $oldPrefs;
}
=head2 SEE ALSO
Modified: trunk/server/scanner.pl
URL: http://svn.slimdevices.com/trunk/server/scanner.pl?rev=11754&r1=11753&r2=11754&view=diff
==============================================================================
--- trunk/server/scanner.pl (original)
+++ trunk/server/scanner.pl Thu Apr 12 10:38:19 2007
@@ -29,16 +29,16 @@
use File::Path;
use File::Spec::Functions qw(:ALL);
+use Slim::Utils::Log;
+use Slim::Utils::Prefs;
use Slim::Music::Import;
use Slim::Music::Info;
use Slim::Music::MusicFolderScan;
use Slim::Music::PlaylistFolderScan;
-use Slim::Utils::Log;
use Slim::Utils::Misc;
use Slim::Utils::MySQLHelper;
use Slim::Utils::OSDetect;
use Slim::Utils::PluginManager;
-use Slim::Utils::Prefs;
use Slim::Utils::Progress;
use Slim::Utils::Scanner;
use Slim::Utils::Strings qw(string);
@@ -59,6 +59,7 @@
'itunes' => \$itunes,
'musicmagic' => \$musicmagic,
'prefsfile=s' => \$prefsFile,
+ # prefsdir parsed by Slim::Utils::Prefs
'progress' => \$progress,
'priority=i' => \$priority,
'logfile=s' => \$logfile,
@@ -261,7 +262,7 @@
--itunes Run the iTunes Importer.
--musicmagic Run the MusicMagic/MusicIP Importer.
--progress Show a progress bar of the scan.
- --prefsfile Specify an alternate prefs file.
+ --prefsdir Specify alternative preferences directory.
--priority set process priority from -20 (high) to 20 (low)
--logfile Send all debugging messages to the specified logfile.
--logdir Specify folder location for log file
Modified: trunk/server/slimserver.pl
URL: http://svn.slimdevices.com/trunk/server/slimserver.pl?rev=11754&r1=11753&r2=11754&view=diff
==============================================================================
--- trunk/server/slimserver.pl (original)
+++ trunk/server/slimserver.pl Thu Apr 12 10:38:19 2007
@@ -111,6 +111,7 @@
}
use Slim::Utils::Log;
+use Slim::Utils::Prefs;
use Slim::Utils::Misc;
use Slim::Utils::PerfMon;
use Slim::Buttons::Common;
@@ -140,7 +141,6 @@
use Slim::Player::Sync;
use Slim::Player::Source;
use Slim::Utils::Cache;
-use Slim::Utils::Prefs;
use Slim::Utils::Scanner;
use Slim::Utils::Scheduler;
use Slim::Networking::Select;
@@ -483,7 +483,7 @@
[--httpport <portnumber> [--httpaddr <listenip>]]
[--cliport <portnumber> [--cliaddr <listenip>]]
[--priority <priority>]
- [--prefsfile <prefsfilepath> [--pidfile <pidfilepath>]]
+ [--prefsdir <prefspath> [--pidfile <pidfilepath>]]
[--perfmon] [--perfwarn=<threshold> | --perfwarn <warn options>]
[--checkstrings] [--debug]
@@ -512,7 +512,7 @@
command line interface server.
--cliaddr => Activate the command line interface TCP/IP
interface on the specified IP address.
- --prefsfile => Specify the path of the the preferences file
+ --prefsdir => Specify the location of the preferences directory
--pidfile => Specify where a process ID file should be stored
--quiet => Minimize the amount of text output
--playeraddr => Specify the _server's_ IP address to use to connect
@@ -559,6 +559,7 @@
'stdio' => \$stdio,
'streamaddr=s' => \$localStreamAddr,
'prefsfile=s' => \$prefsfile,
+ # prefsdir is parsed by Slim::Utils::Prefs prior to initOptions being run
'quiet' => \$quiet,
'nosetup' => \$nosetup,
'noserver' => \$noserver,
More information about the checkins
mailing list