Bug 688 - Indicate when config file can't be written due to lack of disk space
: Indicate when config file can't be written due to lack of disk space
Status: NEW
Product: Logitech Media Server
Classification: Unclassified
Component: Misc
: 5.x or older
: Other RedHat Linux
: -- minor (vote)
: Future
Assigned To: Unassigned bug - please assign me!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-11-26 09:50 UTC by Jesse David Hollington
Modified: 2011-11-06 23:24 UTC (History)
2 users (show)

See Also:
Category: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse David Hollington 2004-11-26 09:50:36 UTC
Related to bug 687, it would be a good idea to put some kind of obvious error
message somewhere when the config file can't be written...  Despite lack of disk
space, I wasn't actually getting a "Can't write" message trying to write to the
config file, even with d_prefs turned on.  The log messages seemed to indicate
that it was writing the config file just fine at every point.  

In this case it wasn't until I actually su'ed to the "slimserver" user and tried
to edit the slimserver.conf file manually that I got a message about being out
of disk space.
Comment 1 Jesse David Hollington 2004-11-26 10:57:11 UTC
Further to this, it would probably be a good idea to not effectively destroy the
config file in the process (once it's truncated to zero bytes, the user's
configuration is lost for all intents and purposes unless they've backed it up
somewhere).

I suspect this may be connected to some of the complaints on the lists about
mysteriously lost config files when upgrading, at least for those on a Linux
platform.
Comment 2 KDF 2005-08-08 11:05:45 UTC
Robert - how well does YAML handle this when calling DumpFile? Do we need to add
any pre-checks?
Comment 3 Robert Moser II 2005-08-08 21:57:21 UTC
Well, all it does is print() a YAML::Dump, so whatever print does when it runs
out of space is what YAML will do.  If we had a way to check free disk space we
could do something like:

my $outprefs = YAML::Dump(\%prefs);
if (check_free_space() > length($outprefs) {
  open NUPREFS, "> $writeFile" or warn "Couldn't open prefs file for write\n";
  print NUPREFS $outprefs or warn "Couldn't output prefs file\n";
  close NUPREFS;
}

If we can't get the free space then we could just use this instead of DumpFile:

  open NUPREFS, "> $writeFile" or warn "Couldn't open prefs file for write\n";
  print NUPREFS YAML::Dump(\%prefs) or warn "Couldn't output prefs file\n";
  close NUPREFS;
Comment 4 Brooks Davis 2006-03-15 16:06:36 UTC
This won't just not save your settings, if the disk is being filled
(say by a moronic process logging that it can't write to the disk
over and over again) the redirect is sufficent to cause the old file
to be deleted and then nothing written.  This ate my entier configuration
recently which really sucked.  Slimserver should really write its
config files in a safer manner, for example (in pseudo code):

write to config.new
move config to config.old
move config.new to config
optionally delete config.old

Then no matter what happens you have a clean copy to recover from.
If move/rename isn't atomic on all platforms (I'm not sure about
Windows) then "move A to B" should be replaced with:

copy A to B
verify that the contents of A and B are identical
remove A

-- Brooks
Comment 5 Robert Moser II 2006-04-08 15:53:51 UTC
Change 6862 uses File::Slurp::write_file to make the writing of the prefs file an atomic action.  Hopefully this will cure the problem of losing all your prefs when your disk is full.  Still no indication, but it's a step in the right direction.
Comment 6 Chris Owens 2008-12-18 11:49:31 UTC
Routine bug db maintenance; removing old versions which cause confusion.  I apologize for the inconvenience.
Comment 7 Alan Young 2011-11-06 23:24:41 UTC
Unassigned bugs cannot have a priority.