Ticket #2051: 0001-Ensure-that-we-close-the-file-descriptors-of-our-tem.patch

File 0001-Ensure-that-we-close-the-file-descriptors-of-our-tem.patch, 1.0 KB (added by lmacken, 14 years ago)
  • journal.py

    From d621d2ba6586a48c0c9411426d2eabb1d51a8127 Mon Sep 17 00:00:00 2001
    From: Luke Macken <lmacken@redhat.com>
    Date: Thu, 17 Jun 2010 08:28:58 -0400
    Subject: [PATCH] Ensure that we close the file descriptors of our tempfile
    
    
    diff --git a/journal.py b/journal.py
    index 8505707..7ef47f2 100644
    a b class JournalInteraction(): 
    330330        #file_path = os.path.join(tempfile.gettempdir(), '%i' % time.time())
    331331        act_root = environ['SUGAR_ACTIVITY_ROOT']
    332332        tmp_dir = join(act_root, 'data')
    333         file_path = str(tempfile.mkstemp(dir=tmp_dir)[1])
     333        tmp_fd, file_path = tempfile.mkstemp(dir=tmp_dir)
    334334        ###TODO: This is such a crappy way to write a file to the journal
    335335        ### Ideally to be implemented with write_file and read_file methods
    336336        os.chmod(file_path, 0777)   
    class JournalInteraction(): 
    365365                jobject.destroy()
    366366                del jobject
    367367        finally:
     368            os.close(tmp_fd)
    368369            os.remove(file_path)
    369370
    370371"""