~mandel/ubuntuone-client/sdtool_start_method

« back to all changes in this revision

Viewing changes to ubuntuone/syncdaemon/file_shelf.py

  • Committer: Manuel de la Pena
  • Date: 2011-06-30 14:21:10 UTC
  • mfrom: (1064.1.1 sdtool_start_method)
  • Revision ID: mandel@themacaque.com-20110630142110-062xprll3eiv7i70
Merged with changes on linux.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import errno
27
27
from collections import deque
28
28
 
 
29
from ubuntuone.platform import open_file
29
30
 
30
31
class FileShelf(object, DictMixin):
31
32
    """ File based shelf.
123
124
 
124
125
        """
125
126
        try:
126
 
            with open(path, "rb") as fd:
 
127
            with open_file(path, "rb") as fd:
127
128
                data = self._unpickle(fd)
128
129
        except (EOFError, cPickle.UnpicklingError, ValueError):
129
130
            # the metadata is broked, try to get .old version if it's available
153
154
        new_path = path+".new"
154
155
        old_path = path+".old"
155
156
        self._check_and_create_dirs(os.path.dirname(path))
156
 
        with open(new_path, "wb") as fh:
 
157
        with open_file(new_path, "wb") as fh:
157
158
            self._pickle(value, fh, protocol=2)
158
159
            fh.flush()
159
160
        if os.path.exists(path):