Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to cope with "disk full" scenarios?

The vast majority of applications does not handle "disk full" scenarios properly.

Example: an installer doesn't see that the disk is full, ignores all errors, and finally happily announces "installation complete!", or an email program is unaware that the message it has just downloaded could not be saved, and tells the server to delete the original.

What techniques are there to handle this situation gracefully? Do you use them? Do you test them?

like image 415
Svante Avatar asked Oct 31 '08 19:10

Svante


1 Answers

As a user, I want software to:

  1. Preserve my data.
  2. Validate my environment as early as possible, before I do any real work.
  3. If #2 is impossible, tell me about any special requirements.
  4. Clean up after itself.

As a developer, techniques to do this include:

  1. Aborting only when there is no alternative, and allowing the user a chance to make a new choice if the previous one fails (see AgentThirteen's answer).
  2. Checking for required resources (memory, disk space, peripherals) as early as possible. Stop immediately if failure is certain; display a warning if success is uncertain, allowing the user to choose whether to continue.
  3. Pre-allocating resources to ensure they will still be available when they are required.
  4. Displaying warnings and errors in non-modal dialogs so the user can place the application in the background and use other tools to fix the problem.
  5. Maintaining an "undo" list: the history of actions that have been performed so far. If the application must abort, offer an opportunity to undo those actions.
like image 183
Adam Liss Avatar answered Sep 28 '22 12:09

Adam Liss