From 3a8d812b6988ed2258ad219b22a256c29910849b Mon Sep 17 00:00:00 2001
From: Aleksey Lim <alsroot@member.fsf.org>
Date: Wed, 2 Jun 2010 10:31:14 +0000
Subject: Failure to cleanup temporary files after filesystem full errors #1876


diff --git a/bin/sugar-session b/bin/sugar-session
old mode 100644
new mode 100755
index 1582b65..cc8358c
--- a/bin/sugar-session
+++ b/bin/sugar-session
@@ -20,6 +20,7 @@ import os
 import sys
 import time
 import subprocess
+import shutil
 
 if os.environ.get('SUGAR_LOGGER_LEVEL', '') == 'debug':
     print '%r STARTUP: Starting the shell' % time.time()
@@ -203,6 +204,10 @@ def set_fonts():
 def main():
     try:
         from sugar import env
+        # Remove temporary files. See http://bugs.sugarlabs.org/ticket/1876
+        data_dir = os.path.join(env.get_profile_path(), 'data')
+        shutil.rmtree(data_dir, ignore_errors=True)
+        os.makedirs(data_dir)
         cleanup_logs(env.get_logs_path())
     except OSError, e:
         # logs cleanup is not critical; it should not prevent sugar from
-- 
1.7.0.4

